function EntityReferenceSupportedNewEntitiesConstraintValidatorTest::testNewEntitiesForbiddenInNonDefaultWorkspace

@covers ::validate

File

core/modules/workspaces/tests/src/Kernel/EntityReferenceSupportedNewEntitiesConstraintValidatorTest.php, line 74

Class

EntityReferenceSupportedNewEntitiesConstraintValidatorTest
@coversDefaultClass \Drupal\workspaces\Plugin\Validation\Constraint\EntityReferenceSupportedNewEntitiesConstraintValidator[[api-linebreak]] @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.