summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php')
-rw-r--r--www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
new file mode 100644
index 00000000..11f0a03b
--- /dev/null
+++ b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0-or-later
+ */
+
+namespace LocalisationUpdate;
+
+/**
+ * @covers \LocalisationUpdate\JSONReader
+ */
+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',
+ ]
+ ];
+ }
+}