diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:17:42 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:17:42 -0400 |
commit | f7d4cf9ed0ae68fec630d14e8f6aade38e49f036 (patch) | |
tree | a730c57badbe0e2f0f064ca2006c82d4b6ed54ea /extensions/LocalisationUpdate/tests/phpunit/reader | |
parent | aee35e4a93d105024bcae947cd8b16c962191f5c (diff) | |
parent | 5d1e7dd0ccda0984ccf3e8e3d0f88ac888b05819 (diff) |
Merge commit '5d1e7'
Diffstat (limited to 'extensions/LocalisationUpdate/tests/phpunit/reader')
-rw-r--r-- | extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php | 37 | ||||
-rw-r--r-- | extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php | 38 |
2 files changed, 75 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', + ) + ); + } +} diff --git a/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php b/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php new file mode 100644 index 00000000..ee155b3a --- /dev/null +++ b/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php @@ -0,0 +1,38 @@ +<?php +/** + * @file + * @author Niklas Laxström + * @license GPL-2.0+ + */ + +class LU_ReaderFactoryTest extends MediaWikiTestCase { + /** + * @dataProvider getReaderProvider + */ + public function testGetReader( $input, $expected, $comment ) { + $factory = new LU_ReaderFactory(); + $reader = $factory->getReader( $input ); + $observed = get_class( $reader ); + $this->assertEquals( $expected, $observed, $comment ); + } + + public function getReaderProvider() { + return array( + array( + 'languages/messages/MessagesFi.php', + 'LU_PHPReader', + 'core php file', + ), + array( + 'extensions/Translate/Translate.i18n.php', + 'LU_PHPReader', + 'extension php file', + ), + array( + 'extension/Translate/i18n/core/de.json', + 'LU_JSONReader', + 'extension json file', + ), + ); + } +} |