You are here

public function EditorSelectionTest::testText in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/quickedit/src/Tests/EditorSelectionTest.php \Drupal\quickedit\Tests\EditorSelectionTest::testText()

Tests a string (plain text) field, with cardinality 1 and >1.

File

core/modules/quickedit/src/Tests/EditorSelectionTest.php, line 53
Contains \Drupal\quickedit\Tests\EditorSelectionTest.

Class

EditorSelectionTest
Tests in-place field editor selection.

Namespace

Drupal\quickedit\Tests

Code

public function testText() {
  $field_name = 'field_text';
  $this
    ->createFieldWithStorage($field_name, 'string', 1, 'Simple text field', array(), 'string_textfield', array(
    'size' => 42,
  ), 'string', array());

  // Create an entity with values for this text field.
  $entity = entity_create('entity_test');
  $entity->{$field_name}->value = 'Hello, world!';
  $entity
    ->save();

  // With cardinality 1.
  $this
    ->assertEqual('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
    ->assertEqual('form', $this
    ->getSelectedEditor($entity
    ->id(), $field_name), "With cardinality >1, the 'form' editor is selected.");
}