function MultiStepNodeFormBasicOptionsTest::testMultiStepNodeFormBasicOptions

Tests changing the default values of basic options to ensure they persist.

File

drupal/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php, line 35
Definition of Drupal\node\Tests\MultiStepNodeFormBasicOptionsTest.

Class

MultiStepNodeFormBasicOptionsTest
Tests basic options of multi-step node forms.

Namespace

Drupal\node\Tests

Code

function testMultiStepNodeFormBasicOptions() {

  // Prepare a user to create the node.
  $web_user = $this
    ->drupalCreateUser(array(
    'administer nodes',
    'create page content',
  ));
  $this
    ->drupalLogin($web_user);

  // Create an unlimited cardinality field.
  $this->field_name = drupal_strtolower($this
    ->randomName());
  $this->field = array(
    'field_name' => drupal_strtolower($this->field_name),
    'type' => 'text',
    'cardinality' => -1,
  );
  field_create_field($this->field);

  // Attach an instance of the field to the page content type.
  $this->instance = array(
    'field_name' => $this->field_name,
    'entity_type' => 'node',
    'bundle' => 'page',
    'label' => $this
      ->randomName() . '_label',
    'settings' => array(
      'text_processing' => TRUE,
    ),
  );
  field_create_instance($this->instance);
  entity_get_form_display('node', 'page', 'default')
    ->setComponent($this->field_name, array(
    'type' => 'text_textfield',
  ))
    ->save();
  $langcode = Language::LANGCODE_NOT_SPECIFIED;
  $edit = array(
    'title' => 'a',
    'promote' => FALSE,
    'sticky' => 1,
    "{$this->field_name}[{$langcode}][0][value]" => $this
      ->randomString(32),
  );
  $this
    ->drupalPost('node/add/page', $edit, t('Add another item'));
  $this
    ->assertNoFieldChecked('edit-promote', 'promote stayed unchecked');
  $this
    ->assertFieldChecked('edit-sticky', 'sticky stayed checked');
}