function TextareaWithSummaryTest::testTextSummaryBehavior

Same name in other branches
  1. 9 core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php \Drupal\Tests\text\FunctionalJavascript\TextareaWithSummaryTest::testTextSummaryBehavior()
  2. 10 core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php \Drupal\Tests\text\FunctionalJavascript\TextareaWithSummaryTest::testTextSummaryBehavior()
  3. 11.x core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php \Drupal\Tests\text\FunctionalJavascript\TextareaWithSummaryTest::testTextSummaryBehavior()

Tests the textSummary javascript behavior.

File

core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php, line 64

Class

TextareaWithSummaryTest
Tests the JavaScript functionality of the text_textarea_with_summary widget.

Namespace

Drupal\Tests\text\FunctionalJavascript

Code

public function testTextSummaryBehavior() {
    // Test with field defaults.
    $this->assertSummaryToggle();
    // Repeat test with non-empty field description.
    $body_field = FieldConfig::loadByName('node', 'page', 'body');
    $body_field->set('description', 'Text with Summary field description.');
    $body_field->save();
    $this->assertSummaryToggle();
    // Test summary is shown when non-empty.
    $node = $this->createNode([
        'body' => [
            [
                'value' => $this->randomMachineName(32),
                'summary' => $this->randomMachineName(32),
                'format' => filter_default_format(),
            ],
        ],
    ]);
    $this->drupalGet('node/' . $node->id() . '/edit');
    $page = $this->getSession()
        ->getPage();
    $summary_field = $page->findField('edit-body-0-summary');
    $this->assertEquals(TRUE, $summary_field->isVisible(), 'Non-empty summary field is shown by default.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.