You are here

public function EditorSelectionTest::testNumber 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::testNumber()

Tests a number field, with cardinality 1 and >1.

File

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

Class

EditorSelectionTest
Tests in-place field editor selection.

Namespace

Drupal\quickedit\Tests

Code

public function testNumber() {
  $field_name = 'field_nr';
  $this
    ->createFieldWithStorage($field_name, 'integer', 1, 'Simple number field', array(), 'number', array(), 'number_integer', array());

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

  // Editor selection with cardinality 1.
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($entity
    ->id(), $field_name), "With cardinality 1, the 'form' editor is selected.");

  // Editor selection with cardinality >1.
  $this->fields->field_nr_field_storage
    ->setCardinality(2);
  $this->fields->field_nr_field_storage
    ->save();
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($entity
    ->id(), $field_name), "With cardinality >1, the 'form' editor is selected.");
}