function EntityDisplayTest::testViewModeAddFormWithoutBundles
Same name and namespace in other branches
- 11.x core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testViewModeAddFormWithoutBundles()
Tests building the view mode add form when an entity type has no bundles.
This is a regression test for https://www.drupal.org/project/drupal/issues/3593466.
File
-
core/
modules/ field_ui/ tests/ src/ Kernel/ EntityDisplayTest.php, line 560
Class
- EntityDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
public function testViewModeAddFormWithoutBundles() : void {
$view_mode = EntityViewMode::create([
'id' => 'node.test',
'label' => 'Test view mode',
'targetEntityType' => 'node',
]);
$view_mode->save();
$form_object = EntityDisplayModeAddForm::create($this->container);
$form_object->setEntityTypeManager($this->container
->get('entity_type.manager'));
$form_object->setModuleHandler($this->container
->get('module_handler'));
$form_object->setEntity($view_mode);
$form = $form_object->buildForm([], new FormState(), 'node');
$this->assertSame([], $this->container
->get('entity_type.bundle.info')
->getBundleInfo('node'));
$this->assertArrayHasKey('id', $form);
$this->assertArrayHasKey('label', $form);
$this->assertArrayHasKey('bundles_by_entity', $form);
$this->assertSame([], $form['bundles_by_entity']['#options']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.