class ComposerMinimumStabilityValidatorTest
@covers \Drupal\package_manager\Validator\ComposerMinimumStabilityValidator @group package_manager @internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
- class \Drupal\Tests\package_manager\Kernel\ComposerMinimumStabilityValidatorTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
Expanded class hierarchy of ComposerMinimumStabilityValidatorTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerMinimumStabilityValidatorTest.php, line 15
Namespace
Drupal\Tests\package_manager\KernelView source
class ComposerMinimumStabilityValidatorTest extends PackageManagerKernelTestBase {
/**
* Tests error if requested version is less stable than the minimum: stable.
*/
public function testPreRequireEvent() : void {
$stage = $this->createStage();
$stage->create();
$result = ValidationResult::createError([
t("<code>drupal/core</code>'s requested version 9.8.1-beta1 is less stable (beta) than the minimum stability (stable) required in <PROJECT_ROOT>/composer.json."),
]);
try {
$stage->require([
'drupal/core:9.8.1-beta1',
]);
$this->fail('Able to require a package even though it did not meet minimum stability.');
} catch (StageEventException $exception) {
$this->assertValidationResultsEqual([
$result,
], $exception->event
->getResults());
}
$stage->destroy();
// Specifying a stability flag bypasses this check.
$stage->create();
$stage->require([
'drupal/core:9.8.1-beta1@dev',
]);
$stage->destroy();
// Dev packages are also checked.
$stage->create();
$result = ValidationResult::createError([
t("<code>drupal/core-dev</code>'s requested version 9.8.x-dev is less stable (dev) than the minimum stability (stable) required in <PROJECT_ROOT>/composer.json."),
]);
try {
$stage->require([], [
'drupal/core-dev:9.8.x-dev',
]);
$this->fail('Able to require a package even though it did not meet minimum stability.');
} catch (StageEventException $exception) {
$this->assertValidationResultsEqual([
$result,
], $exception->event
->getResults());
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.