You are here

class UnpublishedBlockTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block_content/tests/src/Functional/UnpublishedBlockTest.php \Drupal\Tests\block_content\Functional\UnpublishedBlockTest
  2. 9 core/modules/block_content/tests/src/Functional/UnpublishedBlockTest.php \Drupal\Tests\block_content\Functional\UnpublishedBlockTest

Tests unpublishing of block_content entities.

@group block_content

Hierarchy

  • class \Drupal\Tests\block_content\Functional\UnpublishedBlockTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\block\Traits\BlockCreationTrait

Expanded class hierarchy of UnpublishedBlockTest

File

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

Namespace

Drupal\Tests\block_content\Functional
View source
class UnpublishedBlockTest extends BrowserTestBase {
  use BlockCreationTrait;

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'block_content',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

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

}

Members