function ViewsIntegrationTest::setUp

Same name in this branch
  1. 10 core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php \Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest::setUp()
Same name and namespace in other branches
  1. 9 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::setUp()
  2. 9 core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php \Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest::setUp()
  3. 8.9.x core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::setUp()
  4. 8.9.x core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php \Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest::setUp()
  5. 11.x core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::setUp()
  6. 11.x core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php \Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest::setUp()

Sets up the test.

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

array $modules: The module directories to look in for test views.

Overrides ViewTestBase::setUp

File

core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php, line 52

Class

ViewsIntegrationTest
Tests the integration of responsive image with Views.

Namespace

Drupal\Tests\responsive_image\Functional

Code

protected function setUp($import_test_views = TRUE, $modules = [
    'views_test_config',
]) : void {
    parent::setUp($import_test_views, $modules);
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.