function CToolsViewsEntityViewBlockTest::setUp
Overrides UITestBase::setUp
File
-
modules/
ctools_views/ tests/ src/ Functional/ CToolsViewsEntityViewBlockTest.php, line 88
Class
- CToolsViewsEntityViewBlockTest
- Tests the ctools_views block display plugin overriding entity View filters.
Namespace
Drupal\Tests\ctools_views\FunctionalCode
protected function setUp($import_test_views = TRUE, $modules = [
'views_test_config',
]) : void {
parent::setUp();
$this->drupalCreateContentType([
'type' => 'ctools_views',
'name' => 'Ctools views',
]);
// Create test textfield.
FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ctools_views_text',
'type' => 'text',
'cardinality' => 1,
])->save();
FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ctools_views_text',
'bundle' => 'ctools_views',
'label' => 'Ctools Views test textfield',
'translatable' => FALSE,
])->save();
// Create a vocabulary named "Tags".
$vocabulary = Vocabulary::create([
'name' => 'Tags',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$vocabulary->save();
$this->terms[] = $this->createTerm($vocabulary);
$this->terms[] = $this->createTerm($vocabulary);
$this->terms[] = $this->createTerm($vocabulary);
$handler_settings = [
'target_bundles' => [
$vocabulary->id() => $vocabulary->id(),
],
];
$this->createEntityReferenceField('node', 'ctools_views', 'field_ctools_views_tags', 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
// Create list field.
FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ctools_views_list',
'type' => 'list_string',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'settings' => [
'allowed_values' => [
'item1' => "Item 1",
'item2' => "Item 2",
'item3' => "Item 3",
],
],
])->save();
FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ctools_views_list',
'bundle' => 'ctools_views',
'label' => 'Ctools Views List',
'translatable' => FALSE,
])->save();
// Create date field.
FieldStorageConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ctools_views_date',
'type' => 'datetime',
'cardinality' => 1,
'settings' => [
'datetime_type' => 'date',
],
])->save();
FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_ctools_views_date',
'bundle' => 'ctools_views',
'label' => 'Ctools Views Date',
'translatable' => FALSE,
])->save();
ViewTestData::createTestViews(get_class($this), [
'ctools_views_test_views',
]);
$this->storage = $this->container
->get('entity_type.manager')
->getStorage('block');
foreach ($this->testNodes() as $values) {
$entity = Node::create($values);
$entity->save();
$this->entities[] = $entity;
}
}