class ActionValidationTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Kernel/Entity/ActionValidationTest.php \Drupal\Tests\system\Kernel\Entity\ActionValidationTest
- 10 core/modules/system/tests/src/Kernel/Entity/ActionValidationTest.php \Drupal\Tests\system\Kernel\Entity\ActionValidationTest
Tests validation of action entities.
Attributes
#[Group('system')]
#[Group('#slow')]
#[Group('config')]
#[Group('Validation')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \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 extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\system\Kernel\Entity\ActionValidationTest extends \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ActionValidationTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Entity/ ActionValidationTest.php, line 15
Namespace
Drupal\Tests\system\Kernel\EntityView source
class ActionValidationTest extends ConfigEntityValidationTestBase {
/**
* {@inheritdoc}
*/
protected static array $propertiesWithOptionalValues = [
'type',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->entity = Action::create([
'id' => 'test',
'label' => 'Test',
'type' => 'test',
'plugin' => 'action_goto_action',
]);
$this->entity
->save();
}
/**
* Action IDs are atypical in that they allow periods in the machine name.
*/
public static function providerInvalidMachineNameCharacters() : array {
$cases = parent::providerInvalidMachineNameCharacters();
// Remove the existing test case that verifies a machine name containing
// periods is invalid.
self::assertSame([
'period.separated',
FALSE,
], $cases['INVALID: period separated']);
unset($cases['INVALID: period separated']);
// And instead add a test case that verifies it is allowed for blocks.
$cases['VALID: period separated'] = [
'period.separated',
TRUE,
];
return $cases;
}
/**
* Tests that the action plugin ID is validated.
*/
public function testInvalidPluginId() : void {
$this->entity
->set('plugin', 'non_existent');
$this->assertValidationErrors([
'plugin' => "The 'non_existent' plugin does not exist.",
]);
}
/**
* {@inheritdoc}
*/
public function testImmutableProperties(array $valid_values = []) : void {
$valid_values['id'] = 'test_changed';
parent::testImmutableProperties($valid_values);
}
/**
* {@inheritdoc}
*/
public function testLabelValidation() : void {
static::setLabel($this->entity, "Multi\nLine");
$this->assertValidationErrors([
'label' => "Labels are not allowed to span multiple lines or contain control characters.",
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.