2072752d677ec23c4e34dfed1c7bcc3d3df3e3eb
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / composer / ComposerJsonTest.php
1 <?php
2
3 class ComposerJsonTest extends MediaWikiTestCase {
4
5 private $json, $json2;
6
7 public function setUp() {
8 parent::setUp();
9 global $IP;
10 $this->json = "$IP/tests/phpunit/data/composer/composer.json";
11 $this->json2 = "$IP/tests/phpunit/data/composer/new-composer.json";
12 }
13
14 public static function provideGetHash() {
15 return [
16 [ 'json', 'cc6e7fc565b246cb30b0cac103a2b31e' ],
17 [ 'json2', '19921dd1fc457f1b00561da932432001' ],
18 ];
19 }
20
21 /**
22 * @dataProvider provideGetHash
23 * @covers ComposerJson::getHash
24 */
25 public function testIsHashUpToDate( $file, $expected ) {
26 $json = new ComposerJson( $this->$file );
27 $this->assertEquals( $expected, $json->getHash() );
28 }
29
30 /**
31 * @covers ComposerJson::getRequiredDependencies
32 */
33 public function testGetRequiredDependencies() {
34 $json = new ComposerJson( $this->json );
35 $this->assertArrayEquals( [
36 'cdb/cdb' => '1.0.0',
37 'cssjanus/cssjanus' => '1.1.1',
38 'leafo/lessphp' => '0.5.0',
39 'psr/log' => '1.0.0',
40 ], $json->getRequiredDependencies(), false, true );
41 }
42
43 public static function provideNormalizeVersion() {
44 return [
45 [ 'v1.0.0', '1.0.0' ],
46 [ '0.0.5', '0.0.5' ],
47 ];
48 }
49
50 /**
51 * @dataProvider provideNormalizeVersion
52 * @covers ComposerJson::normalizeVersion
53 */
54 public function testNormalizeVersion( $input, $expected ) {
55 $this->assertEquals( $expected, ComposerJson::normalizeVersion( $input ) );
56 }
57 }