protected function FieldRenderedEntityTest::setUpFixtures in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::setUpFixtures()
Sets up the configuration and schema of views and views_test_data modules.
Because the schema of views_test_data.module is dependent on the test using it, it cannot be enabled normally.
Overrides ViewsKernelTestBase::setUpFixtures
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldRenderedEntityTest.php, line 46
Class
- FieldRenderedEntityTest
- Tests the core Drupal\views\Plugin\views\field\RenderedEntity handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
protected function setUpFixtures() {
$this
->installEntitySchema('user');
$this
->installEntitySchema('entity_test');
$this
->installConfig([
'entity_test',
]);
EntityViewMode::create([
'id' => 'entity_test.foobar',
'targetEntityType' => 'entity_test',
'status' => TRUE,
'enabled' => TRUE,
'label' => 'My view mode',
])
->save();
$display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'foobar',
'label' => 'My view mode',
'status' => TRUE,
]);
$display
->save();
$field_storage = FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'type' => 'string',
]);
$field_storage
->save();
$field_config = FieldConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
]);
$field_config
->save();
// Create some test entities.
for ($i = 1; $i <= 3; $i++) {
EntityTest::create([
'name' => "Article title {$i}",
'test_field' => "Test {$i}",
])
->save();
}
$this->user = User::create([
'name' => 'test user',
]);
$this->user
->save();
parent::setUpFixtures();
}