]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / phpunit / includes / GlobalFunctions / GlobalWithDBTest.php
diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
new file mode 100644 (file)
index 0000000..0765ab8
--- /dev/null
@@ -0,0 +1,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:' ],
+               ];
+       }
+}