wiki.techinc.nl/tests/phpunit/unit/includes/libs/composer/ComposerJsonTest.php
Max Semenik 5bf93709f4 Move a lot of libs tests to the unit test directory
Change-Id: Ie7eb1016cd735f07b00524815598581e0d485f2a
2019-11-11 17:53:56 -08:00

41 lines
1 KiB
PHP

<?php
class ComposerJsonTest extends PHPUnit\Framework\TestCase {
private $json, $json2;
public function setUp() : void {
parent::setUp();
$this->json = __DIR__ . "/../../../../data/composer/composer.json";
$this->json2 = __DIR__ . "/../../../../data/composer/new-composer.json";
}
/**
* @covers ComposerJson::__construct
* @covers ComposerJson::getRequiredDependencies
*/
public function testGetRequiredDependencies() {
$json = new ComposerJson( $this->json );
$this->assertEquals( [
'cdb/cdb' => '1.0.0',
'cssjanus/cssjanus' => '1.1.1',
'leafo/lessphp' => '0.5.0',
'psr/log' => '1.0.0',
], $json->getRequiredDependencies() );
}
public static function provideNormalizeVersion() {
return [
[ 'v1.0.0', '1.0.0' ],
[ '0.0.5', '0.0.5' ],
];
}
/**
* @dataProvider provideNormalizeVersion
* @covers ComposerJson::normalizeVersion
*/
public function testNormalizeVersion( $input, $expected ) {
$this->assertEquals( $expected, ComposerJson::normalizeVersion( $input ) );
}
}