ComposerTest.php in Drupal 9
File
core/tests/Drupal/Tests/Composer/ComposerTest.php
View source
<?php
namespace Drupal\Tests\Composer;
use Drupal\Composer\Composer;
use Drupal\Tests\UnitTestCase;
class ComposerTest extends UnitTestCase {
public function testEnsureComposerVersion() {
try {
$this
->assertNull(Composer::ensureComposerVersion());
} catch (\RuntimeException $e) {
$this
->assertMatchesRegularExpression('/Drupal core development requires Composer 1.9.0, but Composer /', $e
->getMessage());
}
}
public function testEnsurePhpConfiguredVersion() {
$composer_json = json_decode(file_get_contents($this->root . '/composer.json'), TRUE);
$composer_core_json = json_decode(file_get_contents($this->root . '/core/composer.json'), TRUE);
$this
->assertEquals(DRUPAL_MINIMUM_PHP, $composer_json['config']['platform']['php'], 'The DRUPAL_MINIMUM_PHP constant should always be exactly the same as the config.platform.php in the root composer.json.');
$this
->assertEquals($composer_core_json['require']['php'], '>=' . $composer_json['config']['platform']['php'], 'The config.platform.php configured version in the root composer.json file should always be exactly the same as the minimum php version configured in core/composer.json.');
}
}