function BlockTest::testTitleContentMessagesSingleBlock

Same name and namespace in other branches
  1. main core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testTitleContentMessagesSingleBlock()

Tests a combined page title, content, and messages block.

File

core/modules/block/tests/src/Functional/BlockTest.php, line 649

Class

BlockTest
Tests basic block functionality.

Namespace

Drupal\Tests\block\Functional

Code

public function testTitleContentMessagesSingleBlock() : void {
  // Place block which implements MainContentBlockPluginInterface,
  // TitleBlockPluginInterface, and MessagesBlockPluginInterface.
  $this->drupalPlaceBlock('test_title_content_message_block');
  $this->drupalGet('');
  // Ensure the block's setTitle function was called.
  $this->assertSession()
    ->pageTextContains('Page title has been placed in the block.');
  // Ensure the block's setMainContent function was called.
  $this->assertSession()
    ->pageTextContains('Main content has been placed in the block.');
  // Ensure the status message is shown.
  $this->assertSession()
    ->statusMessageContains('This is a status message.', 'status');
}

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