function EntityDisplayTest::testDeleteBundle
Tests deleting a bundle.
File
- 
              core/modules/ field_ui/ tests/ src/ Kernel/ EntityDisplayTest.php, line 357 
Class
- EntityDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
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);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
