summaryrefslogtreecommitdiff
path: root/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php')
-rw-r--r--extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php b/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
new file mode 100644
index 00000000..4bb53af9
--- /dev/null
+++ b/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0+
+ */
+
+class LU_JSONReaderTest extends MediaWikiTestCase {
+ /**
+ * @dataProvider parseProvider
+ */
+ public function testParse( $input, $expected, $comment ) {
+ $reader = new LU_JSONReader( 'xx' );
+ $observed = $reader->parse( $input );
+ $this->assertEquals( $expected, $observed['xx'], $comment );
+ }
+
+ public function parseProvider() {
+ return array(
+ array(
+ '{}',
+ array(),
+ 'empty file',
+ ),
+ array(
+ '{"key":"value"}',
+ array( 'key' => 'value' ),
+ 'file with one string',
+ ),
+ array(
+ '{"@metadata":{"authors":["Nike"]},"key":"value2"}',
+ array( 'key' => 'value2' ),
+ '@metadata is ignored',
+ )
+ );
+ }
+}