function EntityDisplayTest::testGetDisplayModeOptions
Same name in other branches
- 9 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testGetDisplayModeOptions()
- 10 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testGetDisplayModeOptions()
- 11.x core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testGetDisplayModeOptions()
Test getDisplayModeOptions().
File
-
core/
modules/ field_ui/ tests/ src/ Kernel/ EntityDisplayTest.php, line 489
Class
- EntityDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
public function testGetDisplayModeOptions() {
NodeType::create([
'type' => 'article',
])->save();
EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'article',
'mode' => 'default',
])->setStatus(TRUE)
->save();
$display_teaser = EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'article',
'mode' => 'teaser',
]);
$display_teaser->save();
EntityFormDisplay::create([
'targetEntityType' => 'user',
'bundle' => 'user',
'mode' => 'default',
])->setStatus(TRUE)
->save();
$form_display_teaser = EntityFormDisplay::create([
'targetEntityType' => 'user',
'bundle' => 'user',
'mode' => 'register',
]);
$form_display_teaser->save();
// Test getViewModeOptionsByBundle().
$view_modes = \Drupal::service('entity_display.repository')->getViewModeOptionsByBundle('node', 'article');
$this->assertEqual($view_modes, [
'default' => 'Default',
]);
$display_teaser->setStatus(TRUE)
->save();
$view_modes = \Drupal::service('entity_display.repository')->getViewModeOptionsByBundle('node', 'article');
$this->assertEqual($view_modes, [
'default' => 'Default',
'teaser' => 'Teaser',
]);
// Test getFormModeOptionsByBundle().
$form_modes = \Drupal::service('entity_display.repository')->getFormModeOptionsByBundle('user', 'user');
$this->assertEqual($form_modes, [
'default' => 'Default',
]);
$form_display_teaser->setStatus(TRUE)
->save();
$form_modes = \Drupal::service('entity_display.repository')->getFormModeOptionsByBundle('user', 'user');
$this->assertEqual($form_modes, [
'default' => 'Default',
'register' => 'Register',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.