function EditorSelectionTest::testNumber

Same name in other branches
  1. 9 core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php \Drupal\Tests\quickedit\Kernel\EditorSelectionTest::testNumber()

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

File

core/modules/quickedit/tests/src/Kernel/EditorSelectionTest.php, line 129

Class

EditorSelectionTest
Tests in-place field editor selection.

Namespace

Drupal\Tests\quickedit\Kernel

Code

public function testNumber() {
    $field_name = 'field_nr';
    $this->createFieldWithStorage($field_name, 'integer', 1, 'Simple number field', [], 'number', [], 'number_integer', []);
    // Create an entity with values for this text field.
    $entity = EntityTest::create();
    $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.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.