Separate MediaWiki unit and integration tests
[lhc/web/wiklou.git] / tests / phpunit / unit / includes / libs / composer / ComposerJsonTest.php
1 <?php
2
3 class ComposerJsonTest extends PHPUnit\Framework\TestCase {
4
5 private $json, $json2;
6
7 public function setUp() {
8 parent::setUp();
9 $this->json = __DIR__ . "/../../../../data/composer/composer.json";
10 $this->json2 = __DIR__ . "/../../../../data/composer/new-composer.json";
11 }
12
13 /**
14 * @covers ComposerJson::__construct
15 * @covers ComposerJson::getRequiredDependencies
16 */
17 public function testGetRequiredDependencies() {
18 $json = new ComposerJson( $this->json );
19 $this->assertEquals( [
20 'cdb/cdb' => '1.0.0',
21 'cssjanus/cssjanus' => '1.1.1',
22 'leafo/lessphp' => '0.5.0',
23 'psr/log' => '1.0.0',
24 ], $json->getRequiredDependencies() );
25 }
26
27 public static function provideNormalizeVersion() {
28 return [
29 [ 'v1.0.0', '1.0.0' ],
30 [ '0.0.5', '0.0.5' ],
31 ];
32 }
33
34 /**
35 * @dataProvider provideNormalizeVersion
36 * @covers ComposerJson::normalizeVersion
37 */
38 public function testNormalizeVersion( $input, $expected ) {
39 $this->assertEquals( $expected, ComposerJson::normalizeVersion( $input ) );
40 }
41 }