function EditorSelectionTest::testText
Same name in other branches
- 8.9.x core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php \Drupal\Tests\quickedit\Kernel\EditorSelectionTest::testText()
Tests a string (plain text) field, with cardinality 1 and >1.
File
-
core/
modules/ quickedit/ tests/ src/ Kernel/ EditorSelectionTest.php, line 57
Class
- EditorSelectionTest
- Tests in-place field editor selection.
Namespace
Drupal\Tests\quickedit\KernelCode
public function testText() {
$field_name = 'field_text';
$this->createFieldWithStorage($field_name, 'string', 1, 'Simple text field', [], 'string_textfield', [
'size' => 42,
], 'string', []);
// Create an entity with values for this text field.
$entity = EntityTest::create();
$entity->{$field_name}->value = 'Hello, world!';
$entity->save();
// With cardinality 1.
$this->assertEquals('plain_text', $this->getSelectedEditor($entity->id(), $field_name), "With cardinality 1, the 'plain_text' editor is selected.");
// With cardinality >1
$this->fields->field_text_field_storage
->setCardinality(2);
$this->fields->field_text_field_storage
->save();
$this->assertEquals('form', $this->getSelectedEditor($entity->id(), $field_name), "With cardinality >1, the 'form' editor is selected.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.