You are here

protected function FieldDefaultsTestBase::setDefaultValues in Field Defaults 8

Sets a default value and runs the batch update.

@TODO: Add support for cardinality @TODO: Add support for language

2 calls to FieldDefaultsTestBase::setDefaultValues()
BooleanTest::testFieldBoolean in src/Tests/BooleanTest.php
Test updating a boolean.
StringTest::testFieldString in src/Tests/StringTest.php
Test updating a boolean.

File

src/Tests/FieldDefaultsTestBase.php, line 131

Class

FieldDefaultsTestBase
Class FieldDefaultsTestBase.

Namespace

Drupal\field_defaults\Tests

Code

protected function setDefaultValues($fieldName, $field_type = 'boolean', $values = [], $contentType = 'page') {
  $this
    ->drupalGet('admin/structure/types/manage/' . $contentType . '/fields/node.' . $contentType . '.field_' . $fieldName);
  $field_setup = $this
    ->setupFieldByType($field_type);

  // Fill out the field form.
  $edit = [
    'default_value_input[field_' . $fieldName . ']' . $field_setup['structure'] => $field_setup['value'],
    'default_value_input[field_defaults][update_defaults]' => TRUE,
  ];

  // Run batch.
  $this
    ->drupalPostForm(NULL, $edit, t('Save settings'));
  $this
    ->assertNoRaw(' ', 'Initial progress message is not double escaped.');

  // Now also go to the next step.
  $this->maximumMetaRefreshCount = 1;
  $this
    ->assertRaw('<li class="messages__item">Default values were updated for 20 entities.</li>');
}