Skip to content
MultiStepNodeFormBasicOptionsTest.php 1.84 KiB
Newer Older
 * Contains \Drupal\node\Tests\MultiStepNodeFormBasicOptionsTest.
 */

namespace Drupal\node\Tests;
use Drupal\Component\Utility\Unicode;
 * Tests the persistence of basic options through multiple steps.
 *
 * @group node
class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
   * Tests changing the default values of basic options to ensure they persist.
   */
  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->fieldName = Unicode::strtolower($this->randomMachineName());
    entity_create('field_storage_config', array(
      'field_name' => $this->fieldName,
      'type' => 'text',
      'cardinality' => -1,

    // Attach an instance of the field to the page content type.
    entity_create('field_config', array(
      'field_name' => $this->fieldName,
      'entity_type' => 'node',
      'bundle' => 'page',
      'label' => $this->randomMachineName() . '_label',
    entity_get_form_display('node', 'page', 'default')
      ->setComponent($this->fieldName, array(
      'promote[value]' => FALSE,
      'sticky[value]' => 1,
      "{$this->fieldName}[0][value]" => $this->randomString(32),
    $this->drupalPostForm('node/add/page', $edit, t('Add another item'));
    $this->assertNoFieldChecked('edit-promote-value', 'Promote stayed unchecked');
    $this->assertFieldChecked('edit-sticky-value', 'Sticky stayed checked');