function ImageTest::setUp

Same name in this branch
  1. 11.x core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()
Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\ImageTest::setUp()
  2. 9 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  3. 9 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()
  4. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  5. 8.9.x core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()
  6. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\ImageTest::setUp()
  7. 10 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  8. 10 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()

Overrides KernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php, line 41

Class

ImageTest
Tests built-in image theme functions.

Namespace

Drupal\KernelTests\Core\Theme

Code

protected function setUp() : void {
    parent::setUp();
    // The code under test uses transformRelative(), which relies on
    // the Request containing the correct hostname. KernelTestBase doesn't set
    // it, so push another request onto the stack to ensure it's correct.
    $request = Request::create('/', 'GET', [], [], [], $_SERVER);
    $request->setSession(new Session(new MockArraySessionStorage()));
    $this->container = \Drupal::service('kernel')->getContainer();
    $this->container
        ->get('request_stack')
        ->push($request);
    $this->fileUrlGenerator = $this->container
        ->get('file_url_generator');
    $this->testImages = [
        'core/misc/druplicon.png',
        'core/misc/loading.svg',
    ];
}

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