function TextareaWithSummaryTest::testTextSummaryRequiredBehavior
Same name in other branches
- 10 core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php \Drupal\Tests\text\FunctionalJavascript\TextareaWithSummaryTest::testTextSummaryRequiredBehavior()
- 11.x core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php \Drupal\Tests\text\FunctionalJavascript\TextareaWithSummaryTest::testTextSummaryRequiredBehavior()
Tests that the textSummary behavior is not run for required summary fields.
File
-
core/
modules/ text/ tests/ src/ FunctionalJavascript/ TextareaWithSummaryTest.php, line 105
Class
- TextareaWithSummaryTest
- Tests the JavaScript functionality of the text_textarea_with_summary widget.
Namespace
Drupal\Tests\text\FunctionalJavascriptCode
public function testTextSummaryRequiredBehavior() {
// Test with field defaults.
$this->assertSummaryToggle();
// Create a second field with a required summary.
$field_name = mb_strtolower($this->randomMachineName());
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'text_with_summary',
]);
$field_storage->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'label' => $this->randomMachineName() . '_label',
'settings' => [
'display_summary' => TRUE,
'required_summary' => TRUE,
],
])
->save();
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$display_repository->getFormDisplay('node', 'page')
->setComponent($field_name, [
'type' => 'text_textarea_with_summary',
])
->save();
$this->drupalGet('node/add/page');
$page = $this->getSession()
->getPage();
$summary_field = $page->findField('edit-' . $field_name . '-0-summary');
$this->assertEquals(TRUE, $summary_field->isVisible());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.