You are here

public function EntityDisplayTest::testDeleteBundle in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testDeleteBundle()

Tests deleting a bundle.

File

core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php, line 349

Class

EntityDisplayTest
Tests the entity display configuration entities.

Namespace

Drupal\Tests\field_ui\Kernel

Code

public function testDeleteBundle() {

  // Create a node bundle, display and form display object.
  $type = NodeType::create([
    'type' => 'article',
  ]);
  $type
    ->save();
  node_add_body_field($type);

  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
  $display_repository = \Drupal::service('entity_display.repository');
  $display_repository
    ->getViewDisplay('node', 'article')
    ->save();
  $display_repository
    ->getFormDisplay('node', 'article')
    ->save();

  // Delete the bundle.
  $type
    ->delete();
  $display = EntityViewDisplay::load('node.article.default');
  $this
    ->assertFalse((bool) $display);
  $form_display = EntityFormDisplay::load('node.article.default');
  $this
    ->assertFalse((bool) $form_display);
}