Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php |
— | — | @@ -235,5 +235,16 @@ |
236 | 236 | public static function disableInterwikis( $prefix, &$data ) { |
237 | 237 | return false; |
238 | 238 | } |
| 239 | + |
| 240 | + /** |
| 241 | + * Don't throw a warning if $function is deprecated and called later |
| 242 | + * |
| 243 | + * @param $function String |
| 244 | + * @return null |
| 245 | + */ |
| 246 | + function hideDeprecated( $function ) { |
| 247 | + wfSuppressWarnings(); |
| 248 | + wfDeprecated( $function ); |
| 249 | + wfRestoreWarnings(); |
| 250 | + } |
239 | 251 | } |
240 | | - |
Index: trunk/phase3/tests/phpunit/includes/BlockTest.php |
— | — | @@ -83,6 +83,27 @@ |
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
| 87 | + * This is the method previously used to load block info in CheckUser etc |
| 88 | + * passing an empty value (empty string, null, etc) as the ip parameter bypasses IP lookup checks. |
| 89 | + * |
| 90 | + * This stopped working with r84475 and friends: regression being fixed for bug 29116. |
| 91 | + * |
| 92 | + * @dataProvider dataBug29116 |
| 93 | + */ |
| 94 | + function testBug29116LoadWithEmptyIp( $vagueTarget ) { |
| 95 | + $this->hideDeprecated( 'Block::load' ); |
| 96 | + |
| 97 | + $uid = User::idFromName( 'UTBlockee' ); |
| 98 | + $this->assertTrue( ($uid > 0), 'Must be able to look up the target user during tests' ); |
| 99 | + |
| 100 | + $block = new Block(); |
| 101 | + $ok = $block->load( $vagueTarget, $uid ); |
| 102 | + $this->assertTrue( $ok, "Block->load() with empty IP and user ID '$uid' should return a block" ); |
| 103 | + |
| 104 | + $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 ) ); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
87 | 108 | * CheckUser since being changed to use Block::newFromTarget started failing |
88 | 109 | * because the new function didn't accept empty strings like Block::load() |
89 | 110 | * had. Regression bug 29116. |
— | — | @@ -102,4 +123,3 @@ |
103 | 124 | ); |
104 | 125 | } |
105 | 126 | } |
106 | | - |