BasicFixedBlockTest.php in Fixed Block Content 8
File
tests/src/Functional/BasicFixedBlockTest.php
View source
<?php
namespace Drupal\Tests\fixed_block_content\Functional;
class BasicFixedBlockTest extends FunctionalFixedBlockTestBase {
public function testContentBlockCreationOnView() {
$this
->drupalGet('<front>');
$content_blocks = \Drupal::entityTypeManager()
->getStorage('block_content')
->loadByProperties([
'info' => $this->fixedBlock
->label(),
]);
$this
->assertTrue(!empty($content_blocks), 'Automatic block content creation failed.');
}
public function testDefaultContent() {
$random_content = $this
->randomString(128);
$block_content = $this->fixedBlock
->getBlockContent();
$block_content
->get('body')
->setValue($random_content);
$this->fixedBlock
->importDefaultContent();
$this->fixedBlock
->save();
$block_content
->delete();
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextContains($random_content);
}
}