* (bug 29426) Fix wrong use of Block::load's second parameter in BlockTest
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 16 Jun 2011 17:58:26 +0000 (17:58 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 16 Jun 2011 17:58:26 +0000 (17:58 +0000)
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

index 06de380..91872d0 100644 (file)
@@ -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 ) );
        }
 
        /**