summaryrefslogtreecommitdiff
path: root/www/wiki/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
blob: 0765ab8b4d644cb98b50c4045e5479062c63e543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

/**
 * @group GlobalFunctions
 * @group Database
 */
class GlobalWithDBTest extends MediaWikiTestCase {
	/**
	 * @dataProvider provideWfIsBadImageList
	 * @covers ::wfIsBadImage
	 */
	public function testWfIsBadImage( $name, $title, $blacklist, $expected, $desc ) {
		$this->assertEquals( $expected, wfIsBadImage( $name, $title, $blacklist ), $desc );
	}

	public static function provideWfIsBadImageList() {
		$blacklist = '* [[File:Bad.jpg]] except [[Nasty page]]';

		return [
			[ 'Bad.jpg', false, $blacklist, true,
				'Called on a bad image' ],
			[ 'Bad.jpg', Title::makeTitle( NS_MAIN, 'A page' ), $blacklist, true,
				'Called on a bad image' ],
			[ 'NotBad.jpg', false, $blacklist, false,
				'Called on a non-bad image' ],
			[ 'Bad.jpg', Title::makeTitle( NS_MAIN, 'Nasty page' ), $blacklist, false,
				'Called on a bad image but is on a whitelisted page' ],
			[ 'File:Bad.jpg', false, $blacklist, false,
				'Called on a bad image with File:' ],
		];
	}
}