class EnvironmentSupportValidatorTest
@covers \Drupal\package_manager\Validator\EnvironmentSupportValidator @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\EnvironmentSupportValidatorTest 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 EnvironmentSupportValidatorTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ EnvironmentSupportValidatorTest.php, line 18
Namespace
Drupal\Tests\package_manager\KernelView source
class EnvironmentSupportValidatorTest extends PackageManagerKernelTestBase {
/**
* Tests handling of an invalid URL in the environment support variable.
*/
public function testInvalidUrl() : void {
putenv(EnvironmentSupportValidator::VARIABLE_NAME . '=broken/url.org');
$result = ValidationResult::createError([
t('Package Manager is not supported by your environment.'),
]);
foreach ([
PreCreateEvent::class,
StatusCheckEvent::class,
] as $event_class) {
$this->assertEventPropagationStopped($event_class, [
$this->container
->get(EnvironmentSupportValidator::class),
'validate',
]);
}
$this->assertStatusCheckResults([
$result,
]);
$this->assertResults([
$result,
], PreCreateEvent::class);
}
/**
* Tests an invalid URL in the environment support variable during pre-apply.
*/
public function testInvalidUrlDuringPreApply() : void {
$this->addEventTestListener(function () : void {
putenv(EnvironmentSupportValidator::VARIABLE_NAME . '=broken/url.org');
});
$result = ValidationResult::createError([
t('Package Manager is not supported by your environment.'),
]);
$this->assertEventPropagationStopped(PreApplyEvent::class, [
$this->container
->get(EnvironmentSupportValidator::class),
'validate',
]);
$this->assertResults([
$result,
], PreApplyEvent::class);
}
/**
* Tests that the validation message links to the provided URL.
*/
public function testValidUrl() : void {
$url = 'http://www.example.com';
putenv(EnvironmentSupportValidator::VARIABLE_NAME . '=' . $url);
$result = ValidationResult::createError([
t('<a href=":url">Package Manager is not supported by your environment.</a>', [
':url' => $url,
]),
]);
$this->assertStatusCheckResults([
$result,
]);
$this->assertResults([
$result,
], PreCreateEvent::class);
}
/**
* Tests that the validation message links to the provided URL during pre-apply.
*/
public function testValidUrlDuringPreApply() : void {
$url = 'http://www.example.com';
$this->addEventTestListener(function () use ($url) : void {
putenv(EnvironmentSupportValidator::VARIABLE_NAME . '=' . $url);
});
$result = ValidationResult::createError([
t('<a href=":url">Package Manager is not supported by your environment.</a>', [
':url' => $url,
]),
]);
$this->assertResults([
$result,
], PreApplyEvent::class);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.