From 13b1da185e9d340ce4c6c38f945c7da37923e6e8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 16 Jun 2011 17:58:26 +0000 Subject: [PATCH] * (bug 29426) Fix wrong use of Block::load's second parameter in BlockTest It was accidentally passing a username where it should have passed a user ID, causing PostgreSQL's stricter comparisons to fail, while MySQL's allowed it to run without complaint but returned bad results. Of course that bug got hidden by the test.... testing the wrong thing... :) Now correctly loads using the user id instead of name, checks the proper return values, and actually compares the right object. --- tests/phpunit/includes/BlockTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index 06de380997..91872d08a1 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -91,9 +91,14 @@ class BlockTest extends MediaWikiLangTestCase { * @dataProvider dataBug29116 */ function testBug29116LoadWithEmptyIp( $vagueTarget ) { + $uid = User::idFromName( 'UTBlockee' ); + $this->assertTrue( ($uid > 0), 'Must be able to look up the target user during tests' ); + $block = new Block(); - $block->load( $vagueTarget, 'UTBlockee' ); - $this->assertTrue( $this->block->equals( Block::newFromTarget('UTBlockee', $vagueTarget) ), "Block->load() returns the same block as the one that was made when given empty ip param " . var_export( $vagueTarget, true ) ); + $ok = $block->load( $vagueTarget, $uid ); + $this->assertTrue( $ok, "Block->load() with empty IP and user ID '$uid' should return a block" ); + + $this->assertTrue( $this->block->equals( $block ), "Block->load() returns the same block as the one that was made when given empty ip param " . var_export( $vagueTarget, true ) ); } /** -- 2.20.1