View source
<?php
namespace Drupal\Tests\fixed_block_content\Kernel;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Lock\PersistentDatabaseLockBackend;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\DependencyInjection\Definition;
abstract class FixedBlockContentKernelTestBase extends KernelTestBase {
public static $modules = [
'field',
'block',
'block_content',
'hal',
'serialization',
'fixed_block_content',
'fixed_block_content_test',
'text',
'filter',
'user',
'system',
];
protected $entityTypeManager;
protected $fixedBlock;
public function register(ContainerBuilder $container) {
parent::register($container);
$container
->setDefinition('lock', new Definition(PersistentDatabaseLockBackend::class, [
$container
->get('database'),
]));
}
protected function setUp() {
parent::setUp();
$this->entityTypeManager = $this->container
->get('entity_type.manager');
$this
->installEntitySchema('user');
$this
->installEntitySchema('block_content');
$this
->installSchema('fixed_block_content', [
'fixed_block_content',
]);
$this
->installConfig([
'system',
'block_content',
'filter',
]);
$this
->createBasicBlockType();
$this
->createFixedBlock();
$this
->installConfig([
'fixed_block_content_test',
]);
}
protected function createBasicBlockType() {
$type = $this->entityTypeManager
->getStorage('block_content_type')
->create([
'id' => 'basic',
'label' => 'Basic',
'revision' => FALSE,
]);
$type
->save();
block_content_add_body_field($type
->id());
}
protected function createFixedBlock() {
$this->fixedBlock = $this->entityTypeManager
->getStorage('fixed_block_content')
->create([
'id' => 'basic_fixed',
'title' => 'Basic fixed',
'block_content_bundle' => 'basic',
]);
$this->fixedBlock
->save();
}
}