class BaseRequirementsFulfilledValidatorTest
@covers \Drupal\package_manager\Validator\BaseRequirementsFulfilledValidator @covers \Drupal\package_manager\Validator\BaseRequirementValidatorTrait
@group package_manager
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\BaseRequirementsFulfilledValidatorTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses \Drupal\package_manager\Validator\BaseRequirementValidatorTrait
- 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 BaseRequirementsFulfilledValidatorTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ BaseRequirementsFulfilledValidatorTest.php, line 23
Namespace
Drupal\Tests\package_manager\KernelView source
class BaseRequirementsFulfilledValidatorTest extends PackageManagerKernelTestBase implements EventSubscriberInterface {
use BaseRequirementValidatorTrait;
/**
* The event class to throw to an error for.
*
* @var string
*/
private string $eventClass;
/**
* {@inheritdoc}
*/
public function validate(PreOperationStageEvent $event) : void {
if (get_class($event) === $this->eventClass) {
$event->addError([
t('This will not stand!'),
]);
}
}
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->container
->get('event_dispatcher')
->addSubscriber($this);
}
/**
* Data provider for ::testBaseRequirement().
*
* @return array[]
* The test cases.
*/
public static function providerBaseRequirement() : array {
return [
[
PreCreateEvent::class,
],
[
PreRequireEvent::class,
],
[
PreApplyEvent::class,
],
[
StatusCheckEvent::class,
],
];
}
/**
* Tests that base requirement failures stop event propagation.
*
* @param string $event_class
* The event which should raise a base requirement error, and thus stop
* event propagation.
*
* @dataProvider providerBaseRequirement
*/
public function testBaseRequirement(string $event_class) : void {
$this->eventClass = $event_class;
$validator = $this->container
->get(BaseRequirementsFulfilledValidator::class);
$this->assertEventPropagationStopped($event_class, [
$validator,
'validate',
]);
$result = ValidationResult::createError([
t('This will not stand!'),
]);
if ($event_class === StatusCheckEvent::class) {
$this->assertStatusCheckResults([
$result,
]);
}
else {
$this->assertResults([
$result,
], $event_class);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.