protected function HookTokensTest::setUp in Node Summary Token From P Tags 1.x
Same name and namespace in other branches
- 1.0.x tests/src/HookTokensTest.php \Drupal\Tests\node_summary_token_from_p\HookTokensTest::setUp()
Overrides TokenReplaceKernelTestBase::setUp
File
- tests/
src/ HookTokensTest.php, line 37
Class
Namespace
Drupal\Tests\node_summary_token_from_pCode
protected function setUp() {
parent::setUp();
$this
->installConfig([
'filter',
'node',
]);
$this
->installEntitySchema('node');
$this
->installSchema('node', [
'node_access',
]);
$article_node_type = NodeType::create([
'type' => 'article',
'name' => 'Article',
]);
$article_node_type
->save();
node_add_body_field($article_node_type);
$article_node_type_without_body = NodeType::create([
'type' => 'article_wo_body',
'name' => 'Article without body',
]);
$article_node_type_without_body
->save();
FilterFormat::create([
'format' => 'html',
'name' => 'html',
'filters' => [],
])
->save();
// Add a text field to the content type.
$field_storage = FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => 'field_text',
'type' => 'text_long',
'cardinality' => 1,
]);
$field_storage
->save();
$field = FieldConfig::create([
'entity_type' => 'node',
'bundle' => 'article_wo_body',
'field_name' => 'field_text',
'label' => 'field_text',
'required' => FALSE,
]);
$field
->save();
/**
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entityDisplayRepository
*/
$entityDisplayRepository = $this->container
->get('entity_display.repository');
// Make sure field_text is shown.
$display = $entityDisplayRepository
->getViewDisplay('node', 'article_wo_body');
$display
->setComponent('field_text', [
'type' => 'text_default',
]);
$display
->save();
$this->cache = $this->container
->get('cache.default');
}