function EntityDisplayTest::testDeleteBundle

Same name and namespace in other branches
  1. 9 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testDeleteBundle()
  2. 8.9.x core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testDeleteBundle()
  3. 11.x 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 351

Class

EntityDisplayTest
Tests the entity display configuration entities.

Namespace

Drupal\Tests\field_ui\Kernel

Code

public function testDeleteBundle() : void {
  // Create a node bundle, display and form display object.
  $type = NodeType::create([
    'type' => 'article',
    'name' => '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);
}

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