]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / extensions / LocalisationUpdate / tests / phpunit / reader / JSONReaderTest.php
diff --git a/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php b/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
new file mode 100644 (file)
index 0000000..bd5c049
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0+
+ */
+
+namespace LocalisationUpdate;
+
+class JSONReaderTest extends \PHPUnit_Framework_TestCase {
+       /**
+        * @dataProvider parseProvider
+        */
+       public function testParse( $input, $expected, $comment ) {
+               $reader = new JSONReader( 'xx' );
+               $observed = $reader->parse( $input );
+               $this->assertEquals( $expected, $observed['xx'], $comment );
+       }
+
+       public function parseProvider() {
+               return [
+                       [
+                               '{}',
+                               [],
+                               'empty file',
+                       ],
+                       [
+                               '{"key":"value"}',
+                               [ 'key' => 'value' ],
+                               'file with one string',
+                       ],
+                       [
+                               '{"@metadata":{"authors":["Nike"]},"key":"value2"}',
+                               [ 'key' => 'value2' ],
+                               '@metadata is ignored',
+                       ]
+               ];
+       }
+}