]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / extensions / LocalisationUpdate / tests / phpunit / reader / JSONReaderTest.php
1 <?php
2 /**
3  * @file
4  * @author Niklas Laxström
5  * @license GPL-2.0+
6  */
7
8 namespace LocalisationUpdate;
9
10 class JSONReaderTest extends \PHPUnit_Framework_TestCase {
11         /**
12          * @dataProvider parseProvider
13          */
14         public function testParse( $input, $expected, $comment ) {
15                 $reader = new JSONReader( 'xx' );
16                 $observed = $reader->parse( $input );
17                 $this->assertEquals( $expected, $observed['xx'], $comment );
18         }
19
20         public function parseProvider() {
21                 return [
22                         [
23                                 '{}',
24                                 [],
25                                 'empty file',
26                         ],
27                         [
28                                 '{"key":"value"}',
29                                 [ 'key' => 'value' ],
30                                 'file with one string',
31                         ],
32                         [
33                                 '{"@metadata":{"authors":["Nike"]},"key":"value2"}',
34                                 [ 'key' => 'value2' ],
35                                 '@metadata is ignored',
36                         ]
37                 ];
38         }
39 }