function EntityViewDisplayValidationTest::testTargetBundleMustExist

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityViewDisplayValidationTest.php \Drupal\KernelTests\Core\Entity\EntityViewDisplayValidationTest::testTargetBundleMustExist()

Tests that the target bundle of the entity view display is checked.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityViewDisplayValidationTest.php, line 80

Class

EntityViewDisplayValidationTest
Tests validation of entity_view_display entities.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testTargetBundleMustExist() : void {
    $this->entity
        ->set('bundle', 'superhero');
    $this->assertValidationErrors([
        '' => "The 'bundle' property cannot be changed.",
        'bundle' => "The 'superhero' bundle does not exist on the 'node' entity type.",
    ]);
}

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