public function DisplayModeUpdateTest::testDisplayModeUpdateAfterFieldCreation in Drupal 8
Same name and namespace in other branches
- 9 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 109
Class
- DisplayModeUpdateTest
- Ensure display modes are updated when fields are created.
Namespace
Drupal\Tests\field\KernelCode
public function testDisplayModeUpdateAfterFieldCreation() {
// 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'));
}