2011-10-27 20:54:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2014-07-18 19:35:43 +00:00
|
|
|
* @group GlobalFunctions
|
2011-10-27 20:54:27 +00:00
|
|
|
* @group Database
|
|
|
|
|
*/
|
|
|
|
|
class GlobalWithDBTest extends MediaWikiTestCase {
|
2019-08-21 08:14:57 +00:00
|
|
|
private function setUpBadImageTests( $name ) {
|
|
|
|
|
if ( in_array( $name, [
|
|
|
|
|
'Hook bad.jpg',
|
|
|
|
|
'Redirect to bad.jpg',
|
|
|
|
|
'Redirect_to_good.jpg',
|
|
|
|
|
'Redirect to hook bad.jpg',
|
|
|
|
|
'Redirect to hook good.jpg',
|
|
|
|
|
] ) ) {
|
|
|
|
|
$this->markTestSkipped( "Didn't get RepoGroup working properly yet" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't try to fetch the files from Commons or anything, please
|
|
|
|
|
$this->setMwGlobals( 'wgForeignFileRepos', [] );
|
|
|
|
|
|
|
|
|
|
// XXX How do we get file redirects to work?
|
|
|
|
|
$this->editPage( 'File:Redirect to bad.jpg', '#REDIRECT [[Bad.jpg]]' );
|
|
|
|
|
$this->editPage( 'File:Redirect to good.jpg', '#REDIRECT [[Good.jpg]]' );
|
|
|
|
|
$this->editPage( 'File:Redirect to hook bad.jpg', '#REDIRECT [[Hook bad.jpg]]' );
|
|
|
|
|
$this->editPage( 'File:Redirect to hook good.jpg', '#REDIRECT [[Hook good.jpg]]' );
|
|
|
|
|
|
2019-08-18 18:19:05 +00:00
|
|
|
$this->setTemporaryHook( 'BadImage', 'BadFileLookupTest::badImageHook' );
|
2019-08-21 08:14:57 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-27 20:54:27 +00:00
|
|
|
/**
|
2019-08-18 18:19:05 +00:00
|
|
|
* @dataProvider BadFileLookupTest::provideIsBadFile
|
2013-10-24 09:53:24 +00:00
|
|
|
* @covers ::wfIsBadImage
|
2011-10-27 20:54:27 +00:00
|
|
|
*/
|
2019-08-21 08:14:57 +00:00
|
|
|
public function testWfIsBadImage( $name, $title, $expected ) {
|
|
|
|
|
$this->setUpBadImageTests( $name );
|
|
|
|
|
|
2019-08-18 18:19:05 +00:00
|
|
|
$this->editPage( 'MediaWiki:Bad image list', BadFileLookupTest::BLACKLIST );
|
2019-08-21 08:14:57 +00:00
|
|
|
$this->resetServices();
|
|
|
|
|
// Enable messages from MediaWiki namespace
|
|
|
|
|
MessageCache::singleton()->enable();
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $expected, wfIsBadImage( $name, $title ) );
|
2011-10-27 20:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-21 08:14:57 +00:00
|
|
|
/**
|
2019-08-18 18:19:05 +00:00
|
|
|
* @dataProvider BadFileLookupTest::provideIsBadFile
|
2019-08-21 08:14:57 +00:00
|
|
|
* @covers ::wfIsBadImage
|
|
|
|
|
*/
|
|
|
|
|
public function testWfIsBadImage_blacklistParam( $name, $title, $expected ) {
|
|
|
|
|
$this->setUpBadImageTests( $name );
|
|
|
|
|
|
2019-08-18 18:19:05 +00:00
|
|
|
$this->hideDeprecated( 'wfIsBadImage with $blacklist parameter' );
|
|
|
|
|
$this->assertSame( $expected, wfIsBadImage( $name, $title, BadFileLookupTest::BLACKLIST ) );
|
2011-10-27 20:54:27 +00:00
|
|
|
}
|
|
|
|
|
}
|