function DisplayModeUpdateTest::testDisplayModeUpdateAfterFieldCreation
Same name in other branches
- 9 core/modules/field/tests/src/Kernel/DisplayModeUpdateTest.php \Drupal\Tests\field\Kernel\DisplayModeUpdateTest::testDisplayModeUpdateAfterFieldCreation()
- 8.9.x core/modules/field/tests/src/Kernel/DisplayModeUpdateTest.php \Drupal\Tests\field\Kernel\DisplayModeUpdateTest::testDisplayModeUpdateAfterFieldCreation()
- 10 core/modules/field/tests/src/Kernel/DisplayModeUpdateTest.php \Drupal\Tests\field\Kernel\DisplayModeUpdateTest::testDisplayModeUpdateAfterFieldCreation()
Ensure display modes are updated when fields are created.
File
-
core/
modules/ field/ tests/ src/ Kernel/ DisplayModeUpdateTest.php, line 113
Class
- DisplayModeUpdateTest
- Ensure display modes are updated when fields are created.
Namespace
Drupal\Tests\field\KernelCode
public function testDisplayModeUpdateAfterFieldCreation() : void {
// Sanity test: field has not been created yet, so should not exist in display.
$this->assertArrayNotHasKey('field_test', \Drupal::config($this->defaultViewDisplayName)
->get('hidden'));
$this->assertArrayNotHasKey('field_test', \Drupal::config($this->defaultFormDisplayName)
->get('hidden'));
$this->assertArrayNotHasKey('field_test', \Drupal::config($this->foobarViewDisplayName)
->get('hidden'));
$this->assertArrayNotHasKey('field_test', \Drupal::config($this->foobarFormDisplayName)
->get('hidden'));
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test',
'type' => 'test_field',
'cardinality' => 1,
]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
])->save();
// Ensure field is added to display modes.
$this->assertArrayHasKey('field_test', \Drupal::config($this->defaultViewDisplayName)
->get('hidden'));
$this->assertArrayHasKey('field_test', \Drupal::config($this->defaultFormDisplayName)
->get('hidden'));
$this->assertArrayHasKey('field_test', \Drupal::config($this->foobarViewDisplayName)
->get('hidden'));
$this->assertArrayHasKey('field_test', \Drupal::config($this->foobarFormDisplayName)
->get('hidden'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.