Merge "Add ext-dom to composer.json"
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / GlobalWithDBTest.php
1 <?php
2
3 /**
4 * @group GlobalFunctions
5 * @group Database
6 */
7 class GlobalWithDBTest extends MediaWikiTestCase {
8 private function setUpBadImageTests( $name ) {
9 if ( in_array( $name, [
10 'Hook bad.jpg',
11 'Redirect to bad.jpg',
12 'Redirect_to_good.jpg',
13 'Redirect to hook bad.jpg',
14 'Redirect to hook good.jpg',
15 ] ) ) {
16 $this->markTestSkipped( "Didn't get RepoGroup working properly yet" );
17 }
18
19 // Don't try to fetch the files from Commons or anything, please
20 $this->setMwGlobals( 'wgForeignFileRepos', [] );
21
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]]' );
27
28 $this->setTemporaryHook( 'BadImage', 'BadFileLookupTest::badImageHook' );
29 }
30
31 /**
32 * @dataProvider BadFileLookupTest::provideIsBadFile
33 * @covers ::wfIsBadImage
34 */
35 public function testWfIsBadImage( $name, $title, $expected ) {
36 $this->setUpBadImageTests( $name );
37
38 $this->editPage( 'MediaWiki:Bad image list', BadFileLookupTest::BLACKLIST );
39 $this->resetServices();
40 // Enable messages from MediaWiki namespace
41 MessageCache::singleton()->enable();
42
43 $this->assertEquals( $expected, wfIsBadImage( $name, $title ) );
44 }
45
46 /**
47 * @dataProvider BadFileLookupTest::provideIsBadFile
48 * @covers ::wfIsBadImage
49 */
50 public function testWfIsBadImage_blacklistParam( $name, $title, $expected ) {
51 $this->setUpBadImageTests( $name );
52
53 $this->hideDeprecated( 'wfIsBadImage with $blacklist parameter' );
54 $this->assertSame( $expected, wfIsBadImage( $name, $title, BadFileLookupTest::BLACKLIST ) );
55 }
56 }