4 * @group GlobalFunctions
7 class GlobalWithDBTest
extends MediaWikiTestCase
{
8 private function setUpBadImageTests( $name ) {
9 if ( in_array( $name, [
11 'Redirect to bad.jpg',
12 'Redirect_to_good.jpg',
13 'Redirect to hook bad.jpg',
14 'Redirect to hook good.jpg',
16 $this->markTestSkipped( "Didn't get RepoGroup working properly yet" );
19 // Don't try to fetch the files from Commons or anything, please
20 $this->setMwGlobals( 'wgForeignFileRepos', [] );
22 // XXX How do we get file redirects to work?
23 $this->editPage( 'File:Redirect to bad.jpg', '#REDIRECT [[Bad.jpg]]' );
24 $this->editPage( 'File:Redirect to good.jpg', '#REDIRECT [[Good.jpg]]' );
25 $this->editPage( 'File:Redirect to hook bad.jpg', '#REDIRECT [[Hook bad.jpg]]' );
26 $this->editPage( 'File:Redirect to hook good.jpg', '#REDIRECT [[Hook good.jpg]]' );
28 $this->setTemporaryHook( 'BadImage', 'BadFileLookupTest::badImageHook' );
32 * @dataProvider BadFileLookupTest::provideIsBadFile
33 * @covers ::wfIsBadImage
35 public function testWfIsBadImage( $name, $title, $expected ) {
36 $this->setUpBadImageTests( $name );
38 $this->editPage( 'MediaWiki:Bad image list', BadFileLookupTest
::BLACKLIST
);
39 $this->resetServices();
40 // Enable messages from MediaWiki namespace
41 MessageCache
::singleton()->enable();
43 $this->assertEquals( $expected, wfIsBadImage( $name, $title ) );
47 * @dataProvider BadFileLookupTest::provideIsBadFile
48 * @covers ::wfIsBadImage
50 public function testWfIsBadImage_blacklistParam( $name, $title, $expected ) {
51 $this->setUpBadImageTests( $name );
53 $this->hideDeprecated( 'wfIsBadImage with $blacklist parameter' );
54 $this->assertSame( $expected, wfIsBadImage( $name, $title, BadFileLookupTest
::BLACKLIST
) );