function DisplayModeUpdateTest::setUp
Same name in other branches
- 9 core/modules/field/tests/src/Kernel/DisplayModeUpdateTest.php \Drupal\Tests\field\Kernel\DisplayModeUpdateTest::setUp()
- 8.9.x core/modules/field/tests/src/Kernel/DisplayModeUpdateTest.php \Drupal\Tests\field\Kernel\DisplayModeUpdateTest::setUp()
- 11.x core/modules/field/tests/src/Kernel/DisplayModeUpdateTest.php \Drupal\Tests\field\Kernel\DisplayModeUpdateTest::setUp()
Overrides FieldKernelTestBase::setUp
File
-
core/
modules/ field/ tests/ src/ Kernel/ DisplayModeUpdateTest.php, line 52
Class
- DisplayModeUpdateTest
- Ensure display modes are updated when fields are created.
Namespace
Drupal\Tests\field\KernelCode
protected function setUp() : void {
parent::setUp();
// Create 'default' view-display.
$default_view_display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'status' => TRUE,
]);
$default_view_display->save();
$this->defaultViewDisplayName = $default_view_display->getConfigDependencyName();
// Create 'default' form-display.
$default_form_display = EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'status' => TRUE,
]);
$default_form_display->save();
$this->defaultFormDisplayName = $default_form_display->getConfigDependencyName();
// Create a view-mode 'foobar', create view-display that uses it.
EntityViewMode::create([
'id' => 'entity_test.foobar',
'label' => 'Foobar',
'targetEntityType' => 'entity_test',
'status' => TRUE,
'enabled' => TRUE,
])->save();
$foobar_view_display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'foobar',
'status' => TRUE,
]);
$foobar_view_display->save();
$this->foobarViewDisplayName = $foobar_view_display->getConfigDependencyName();
// Create a new form-mode 'foobar', create form-display that uses it.
EntityFormMode::create([
'id' => 'entity_test.foobar',
'label' => 'Foobar',
'targetEntityType' => 'entity_test',
'status' => TRUE,
'enabled' => TRUE,
])->save();
$foobar_form_display = EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'foobar',
'status' => TRUE,
]);
$foobar_form_display->save();
$this->foobarFormDisplayName = $foobar_form_display->getConfigDependencyName();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.