3 namespace Drupal\Tests\node\Functional;
5 use Drupal\Component\Utility\Unicode;
6 use Drupal\field\Entity\FieldConfig;
7 use Drupal\field\Entity\FieldStorageConfig;
10 * Tests the persistence of basic options through multiple steps.
14 class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
17 * The field name to create.
24 * Tests changing the default values of basic options to ensure they persist.
26 public function testMultiStepNodeFormBasicOptions() {
27 // Prepare a user to create the node.
28 $web_user = $this->drupalCreateUser(['administer nodes', 'create page content']);
29 $this->drupalLogin($web_user);
31 // Create an unlimited cardinality field.
32 $this->fieldName = Unicode::strtolower($this->randomMachineName());
33 FieldStorageConfig::create([
34 'field_name' => $this->fieldName,
35 'entity_type' => 'node',
40 // Attach an instance of the field to the page content type.
42 'field_name' => $this->fieldName,
43 'entity_type' => 'node',
45 'label' => $this->randomMachineName() . '_label',
47 entity_get_form_display('node', 'page', 'default')
48 ->setComponent($this->fieldName, [
49 'type' => 'text_textfield',
54 'title[0][value]' => 'a',
55 'promote[value]' => FALSE,
57 "{$this->fieldName}[0][value]" => $this->randomString(32),
59 $this->drupalPostForm('node/add/page', $edit, t('Add another item'));
60 $this->assertNoFieldChecked('edit-promote-value', 'Promote stayed unchecked');
61 $this->assertFieldChecked('edit-sticky-value', 'Sticky stayed checked');