public function EntityReferenceSupportedNewEntitiesConstraintValidatorTest::testNewEntitiesForbiddenInNonDefaultWorkspace in Drupal 9
Same name and namespace in other branches
- 8 core/modules/workspaces/tests/src/Kernel/EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php \Drupal\Tests\workspaces\Kernel\EntityReferenceSupportedNewEntitiesConstraintValidatorTest::testNewEntitiesForbiddenInNonDefaultWorkspace()
@covers ::validate
File
- core/
modules/ workspaces/ tests/ src/ Kernel/ EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php, line 67
Class
- EntityReferenceSupportedNewEntitiesConstraintValidatorTest
- @coversDefaultClass \Drupal\workspaces\Plugin\Validation\Constraint\EntityReferenceSupportedNewEntitiesConstraintValidator @group workspaces
Namespace
Drupal\Tests\workspaces\KernelCode
public function testNewEntitiesForbiddenInNonDefaultWorkspace() {
$this
->switchToWorkspace('stage');
$entity = EntityTestMulRevPub::create([
'unsupported_reference' => [
'entity' => EntityTest::create([]),
],
'supported_reference' => [
'entity' => EntityTestMulRevPub::create([]),
],
]);
$violations = $entity
->validate();
$this
->assertCount(1, $violations);
$this
->assertEquals('<em class="placeholder">Test entity entities</em> can only be created in the default workspace.', $violations[0]
->getMessage());
}