protected function ViewsIntegrationTest::setUp in Drupal 9
Same name in this branch
- 9 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::setUp()
- 9 core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php \Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest::setUp()
Same name and namespace in other branches
- 8 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::setUp()
Overrides ViewTestBase::setUp
File
- core/
modules/ responsive_image/ tests/ src/ Functional/ ViewsIntegrationTest.php, line 50
Class
- ViewsIntegrationTest
- Tests the integration of responsive image with Views.
Namespace
Drupal\Tests\responsive_image\FunctionalCode
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this
->enableViewsTestModule();
// Create a responsive image style.
$responsive_image_style = ResponsiveImageStyle::create([
'id' => self::RESPONSIVE_IMAGE_STYLE_ID,
'label' => 'Foo',
'breakpoint_group' => 'responsive_image_test_module',
]);
// Create an image field to be used with a responsive image formatter.
FieldStorageConfig::create([
'type' => 'image',
'entity_type' => 'entity_test',
'field_name' => 'bar',
])
->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'field_name' => 'bar',
])
->save();
$responsive_image_style
->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'thumbnail',
])
->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'medium',
])
->addImageStyleMapping('responsive_image_test_module.wide', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => 'large',
])
->save();
$admin_user = $this
->drupalCreateUser([
'administer views',
]);
$this
->drupalLogin($admin_user);
}