You are here

public function UnpublishedBlockTest::testViewShowsCorrectStates in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/block_content/tests/src/Functional/UnpublishedBlockTest.php \Drupal\Tests\block_content\Functional\UnpublishedBlockTest::testViewShowsCorrectStates()

Tests unpublishing of block_content entities.

File

core/modules/block_content/tests/src/Functional/UnpublishedBlockTest.php, line 31

Class

UnpublishedBlockTest
Tests unpublishing of block_content entities.

Namespace

Drupal\Tests\block_content\Functional

Code

public function testViewShowsCorrectStates() {
  $block_content = BlockContent::create([
    'info' => 'Test block',
    'type' => 'basic',
  ]);
  $block_content
    ->save();
  $this
    ->placeBlock('block_content:' . $block_content
    ->uuid());
  $this
    ->drupalGet('<front>');
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->assertTrue($page
    ->has('css', '.block-block-content' . $block_content
    ->uuid()));
  $block_content
    ->setUnpublished();
  $block_content
    ->save();
  $this
    ->drupalGet('<front>');
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->assertFalse($page
    ->has('css', '.block-block-content' . $block_content
    ->uuid()));
}