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