diff -u b/core/modules/field/tests/src/FunctionalJavascript/FormTest.php b/core/modules/field/tests/src/FunctionalJavascript/FormTest.php --- b/core/modules/field/tests/src/FunctionalJavascript/FormTest.php +++ b/core/modules/field/tests/src/FunctionalJavascript/FormTest.php @@ -2,31 +2,22 @@ namespace Drupal\Tests\field\FunctionalJavascript; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; +use Drupal\FunctionalJavascriptTests\JavascriptTestBase; /** - * Tests the JavaScript library caching on consecutive requests. + * Tests add more behavior for a multiple value field. * - * @group views_ui + * @group field */ -class FormTest extends JavascriptTestBase { - - /** - * An array of values defining a field with unlimited cardinality. - * - * @var array - */ - protected $fieldStorageUnlimited; - +class FormJSAddMoreTest extends JavascriptTestBase { /** - * An array of values defining a field. - * - * @var array + * {@inheritdoc} */ - protected $field; + public static $modules = ['field_test', 'entity_test']; /** * {@inheritdoc} @@ -40,15 +31,9 @@ ]); $this->drupalLogin($account); - $this->fieldStorageUnlimited = array( + $field = array( 'field_name' => 'field_unlimited', 'entity_type' => 'entity_test', - 'type' => 'test_field', - 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, - ); - - $this->field = array( - 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $this->randomMachineName() . '_label', 'description' => '[site:name]_description', @@ -58,21 +43,17 @@ ), ); - $field_storage = $this->fieldStorageUnlimited; - $field_name = $field_storage['field_name']; - $this->field['field_name'] = $field_name; - - FieldStorageConfig::create($field_storage)->save(); - FieldConfig::create($this->field)->save(); - entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default') - ->setComponent($field_name) - ->save(); - } + FieldStorageConfig::create(array( + 'field_name' => 'field_unlimited', + 'entity_type' => 'entity_test', + 'type' => 'test_field', + 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + ))->save(); + FieldConfig::create($field)->save(); - /** - * {@inheritdoc} - */ - public static $modules = ['field_test', 'entity_test']; + $entity_form_display = EntityFormDisplay::load($field['entity_type'] . '.' . $field['bundle'] . '.default'); + $entity_form_display->setComponent($field['field_name'])->save(); + } function testFieldFormJSAddMore() { $this->drupalGet('entity_test/add'); @@ -91,7 +72,7 @@ // Validate the existence of the new field. $field_1 = $page->findField('field_unlimited[1][value]'); - $this->assertNotEmpty($field_1, 'Succesfully added another item.'); + $this->assertNotEmpty($field_1, 'Successfully added another item.'); // Validate the value of the first field has not changed. $this->assertEquals($field_0->getValue(), '1', 'Value for the first item has not changed.'); @@ -105,7 +86,7 @@ // Assert successful creation. $field_2 = $page->findField('field_unlimited[2][value]'); - $this->assertNotEmpty($field_2, 'Succesfully added another item.'); + $this->assertNotEmpty($field_2, 'Successfully added another item.'); // Set values for the 2nd and 3rd fields to validate dragging. $field_1->setValue('2');