class MultiStepNodeFormBasicOptionsTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php \Drupal\Tests\node\Functional\MultiStepNodeFormBasicOptionsTest
- 7.x modules/node/node.test \MultiStepNodeFormBasicOptionsTest
- 10 core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php \Drupal\Tests\node\Functional\MultiStepNodeFormBasicOptionsTest
- 8.9.x core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php \Drupal\Tests\node\Functional\MultiStepNodeFormBasicOptionsTest
Tests the persistence of basic options through multiple steps.
@group node
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Functional\NodeTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\node\Functional\MultiStepNodeFormBasicOptionsTest extends \Drupal\Tests\node\Functional\NodeTestBase
- class \Drupal\Tests\node\Functional\NodeTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of MultiStepNodeFormBasicOptionsTest
File
-
core/
modules/ node/ tests/ src/ Functional/ MultiStepNodeFormBasicOptionsTest.php, line 13
Namespace
Drupal\Tests\node\FunctionalView source
class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* The field name to create.
*
* @var string
*/
protected $fieldName;
/**
* Tests changing the default values of basic options to ensure they persist.
*/
public function testMultiStepNodeFormBasicOptions() {
// Prepare a user to create the node.
$web_user = $this->drupalCreateUser([
'administer nodes',
'create page content',
]);
$this->drupalLogin($web_user);
// Create an unlimited cardinality field.
$this->fieldName = mb_strtolower($this->randomMachineName());
FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text',
'cardinality' => -1,
])
->save();
// Attach an instance of the field to the page content type.
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => 'page',
'label' => $this->randomMachineName() . '_label',
])
->save();
\Drupal::service('entity_display.repository')->getFormDisplay('node', 'page')
->setComponent($this->fieldName, [
'type' => 'text_textfield',
])
->save();
$edit = [
'title[0][value]' => 'a',
'promote[value]' => FALSE,
'sticky[value]' => 1,
"{$this->fieldName}[0][value]" => $this->randomString(32),
];
$this->drupalGet('node/add/page');
$this->submitForm($edit, 'Add another item');
$this->assertSession()
->checkboxNotChecked('edit-promote-value');
$this->assertSession()
->checkboxChecked('edit-sticky-value');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.