EntityViewTest.php in Rules 8.3
File
tests/src/Kernel/EntityViewTest.php
View source
<?php
namespace Drupal\Tests\rules\Kernel;
class EntityViewTest extends RulesKernelTestBase {
protected static $modules = [
'field',
'node',
'text',
'user',
];
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installConfig([
'system',
]);
$this
->installConfig([
'field',
]);
$this
->installConfig([
'node',
]);
$this
->installSchema('system', [
'sequences',
]);
}
public function testEntityViewHook() {
$entity_type_manager = $this->container
->get('entity_type.manager');
$entity_type_manager
->getStorage('node_type')
->create([
'type' => 'page',
'display_submitted' => FALSE,
])
->save();
$node = $entity_type_manager
->getStorage('node')
->create([
'title' => 'test',
'type' => 'page',
]);
$node
->save();
$view_builder = $entity_type_manager
->getViewBuilder('node');
$build = $view_builder
->view($node);
$this->container
->get('renderer')
->renderPlain($build);
}
}