'settings[comment_type]' => 'foobar',
];
$this->
fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment',
$storage_edit);
// Add a third comment field.
$this->
fieldUIAddNewField('entity_test/structure/entity_test', 'barfoo', 'BarFoo', 'comment',
$storage_edit);
// Check the field contains the correct comment type.
$field_storage = FieldStorageConfig::
load('entity_test.field_barfoo'
);
$this->
assertInstanceOf(FieldStorageConfig::
class,
$field_storage);
$this->
assertEquals('foobar',
$field_storage->
getSetting('comment_type'
));
$this->
assertEquals(1,
$field_storage->
getCardinality());
// Test the new entity commenting inherits default.
$random_label =
$this->
randomMachineName();
$data =
['bundle' => 'entity_test', 'name' =>
$random_label];
$new_entity = EntityTest::
create($data);
$new_entity->
save();
$this->
drupalGet('entity_test/manage/' .
$new_entity->
id() . '/edit'
);
$this->
assertSession()->
checkboxNotChecked('edit-field-foobar-0-status-1'
);
$this->
assertSession()->
checkboxChecked('edit-field-foobar-0-status-2'
);
$this->
assertSession()->
fieldNotExists('edit-field-foobar-0-status-0'
);