diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-04-01 06:11:44 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-04-01 06:11:44 +0200 |
commit | 14f74d141ab5580688bfd46d2f74c026e43ed967 (patch) | |
tree | 081b7cbfc4d246ecc42831978d080331267cf57c /extensions/LocalisationUpdate/tests/phpunit/reader | |
parent | 4a953b6bfda28604979feb9cfbb58974d13b84bb (diff) |
Update to MediaWiki 1.24.2
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', + ), + ); + } +} |