function EntityReferenceSupportedNewEntitiesConstraintValidatorTest::testNewEntitiesForbiddenInNonDefaultWorkspace

Same name and namespace in other branches
  1. 9 core/modules/workspaces/tests/src/Kernel/EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php \Drupal\Tests\workspaces\Kernel\EntityReferenceSupportedNewEntitiesConstraintValidatorTest::testNewEntitiesForbiddenInNonDefaultWorkspace()
  2. 10 core/modules/workspaces/tests/src/Kernel/EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php \Drupal\Tests\workspaces\Kernel\EntityReferenceSupportedNewEntitiesConstraintValidatorTest::testNewEntitiesForbiddenInNonDefaultWorkspace()
  3. 11.x 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 <a href="/api/drupal/core%21modules%21workspaces%21src%21Plugin%21Validation%21Constraint%21EntityReferenceSupportedNewEntitiesConstraintValidator.php/class/EntityReferenceSupportedNewEntitiesConstraintValidator/8.9.x" title="Checks if new entities created for entity reference fields are supported." class="local">\Drupal\workspaces\Plugin\Validation\Constraint\EntityReferenceSupportedNewEntitiesConstraintValidator</a> @group workspaces

Namespace

Drupal\Tests\workspaces\Kernel

Code

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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.