function EditorSelectionTest::testNumber

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

File

drupal/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php, line 145
Contains \Drupal\edit\Tests\EditorSelectionTest.

Class

EditorSelectionTest
Test in-place field editor selection.

Namespace

Drupal\edit\Tests

Code

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

  // Pretend there is an entity with these items for the field.
  $items = array(
    42,
    43,
  );

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

  // Editor selection with cardinality >1.
  $this->field_nr_field['cardinality'] = 2;
  field_update_field($this->field_nr_field);
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($items, $field_name), "With cardinality >1, the 'form' editor is selected.");
}