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', [] );
21 // We need to reset services immediately so that editPage() doesn't use the old RepoGroup
22 // and hit the network
23 $this->resetServices();
25 // XXX How do we get file redirects to work?
26 $this->editPage( 'File:Redirect to bad.jpg', '#REDIRECT [[Bad.jpg]]' );
27 $this->editPage( 'File:Redirect to good.jpg', '#REDIRECT [[Good.jpg]]' );
28 $this->editPage( 'File:Redirect to hook bad.jpg', '#REDIRECT [[Hook bad.jpg]]' );
29 $this->editPage( 'File:Redirect to hook good.jpg', '#REDIRECT [[Hook good.jpg]]' );
31 $this->setTemporaryHook( 'BadImage', 'BadFileLookupTest::badImageHook' );
35 * @dataProvider BadFileLookupTest::provideIsBadFile
36 * @covers ::wfIsBadImage
38 public function testWfIsBadImage( $name, $title, $expected ) {
39 $this->setUpBadImageTests( $name );
41 $this->editPage( 'MediaWiki:Bad image list', BadFileLookupTest
::BLACKLIST
);
42 $this->resetServices();
43 // Enable messages from MediaWiki namespace
44 MessageCache
::singleton()->enable();
46 $this->assertEquals( $expected, wfIsBadImage( $name, $title ) );
50 * @dataProvider BadFileLookupTest::provideIsBadFile
51 * @covers ::wfIsBadImage
53 public function testWfIsBadImage_blacklistParam( $name, $title, $expected ) {
54 $this->setUpBadImageTests( $name );
56 $this->hideDeprecated( 'wfIsBadImage with $blacklist parameter' );
57 $this->assertSame( $expected, wfIsBadImage( $name, $title, BadFileLookupTest
::BLACKLIST
) );