From: Aaron Schulz Date: Mon, 25 Jul 2011 16:27:33 +0000 (+0000) Subject: Reverted r92489 and added/use hideDeprecated() to MW test framework X-Git-Tag: 1.31.0-rc.0~28643 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=a108dbfe8f7f20f22d6513838022d50bbdc17165;p=lhc%2Fweb%2Fwiklou.git Reverted r92489 and added/use hideDeprecated() to MW test framework --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 64cb486b5d..fb6baf68fc 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -235,5 +235,16 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { public static function disableInterwikis( $prefix, &$data ) { return false; } -} + /** + * Don't throw a warning if $function is deprecated and called later + * + * @param $function String + * @return null + */ + function hideDeprecated( $function ) { + wfSuppressWarnings(); + wfDeprecated( $function ); + wfRestoreWarnings(); + } +} diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index dff5dfe520..cc6ed9241b 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -82,6 +82,27 @@ class BlockTest extends MediaWikiLangTestCase { } + /** + * This is the method previously used to load block info in CheckUser etc + * passing an empty value (empty string, null, etc) as the ip parameter bypasses IP lookup checks. + * + * This stopped working with r84475 and friends: regression being fixed for bug 29116. + * + * @dataProvider dataBug29116 + */ + function testBug29116LoadWithEmptyIp( $vagueTarget ) { + $this->hideDeprecated( 'Block::load' ); + + $uid = User::idFromName( 'UTBlockee' ); + $this->assertTrue( ($uid > 0), 'Must be able to look up the target user during tests' ); + + $block = new Block(); + $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 ) ); + } + /** * CheckUser since being changed to use Block::newFromTarget started failing * because the new function didn't accept empty strings like Block::load() @@ -102,4 +123,3 @@ class BlockTest extends MediaWikiLangTestCase { ); } } -