You are here

public function BlockContentTypeTest::testBlockContentView in Acquia Content Hub 8

Checks the acquia-contenthub block view functionality.

2 methods override BlockContentTypeTest::testBlockContentView()
BlockContentTypeHooksTest::testBlockContentView in tests/src/Functional/BlockContentTypeHooksTest.php
Checks the acquia-contenthub block hooks functionality.
BlockContentTypeTemplatesTest::testBlockContentView in tests/src/Functional/BlockContentTypeTemplatesTest.php
Checks the acquia-contenthub block templates functionality.

File

tests/src/Functional/BlockContentTypeTest.php, line 39

Class

BlockContentTypeTest
Create a block and test block markup by attempting to view the block.

Namespace

Drupal\Tests\acquia_contenthub\Functional

Code

public function testBlockContentView() {
  $this
    ->drupalLogin($this->adminUser);
  $block = $this
    ->createBlockContent();
  $block
    ->set('body', 'block_body_value');
  $block
    ->save();

  // Attempt to view the block.
  $this
    ->drupalGet('acquia-contenthub/display/block_content/' . $block
    ->id() . '/default');
  $this
    ->assertResponse(200, "Assert response was '200' and not '403 Access denied'");
  $this
    ->assertRaw($block
    ->get('body')
    ->getString(), 'Body field is present.');
  $this
    ->assertNoRaw($block
    ->label(), 'Label field is absent.');
  $this
    ->removeWhiteSpace();
  $expected = '</head><body><div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>block_body_value</p></div><div data-content-barrier-exclude="true"></div></body></html>';
  $this
    ->assertRaw($expected, 'The block--block-content--acquia-contenthub.html.twig template have no extra markup.');
  $this
    ->assertOffCanvasWrapperRemoved();
}