public function testEntityFormModeAlter() { // Create compact entity display.
EntityFormMode::
create(['id' => 'entity_test.compact', 'targetEntityType' => 'entity_test'
])->
save();
EntityFormDisplay::
create([ 'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'compact',
'status' => TRUE,
])->
removeComponent('field_test_text'
)->
save();
// The field should be available on default form mode.
$entity1 = EntityTest::
create([ 'name' =>
$this->
randomString(),
]);
$entity1->
save();
$this->
drupalGet($entity1->
toUrl('edit-form'
));
$this->
assertSession()->
elementExists('css', 'input[name="field_test_text[0][value]"]'
);
// The field should be hidden on compact form mode.
// See: entity_test_entity_form_mode_alter().