You are here

public function ImageStyleCustomStreamWrappersTest::testCustomStreamWrappers in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/image/tests/src/Kernel/ImageStyleCustomStreamWrappersTest.php \Drupal\Tests\image\Kernel\ImageStyleCustomStreamWrappersTest::testCustomStreamWrappers()
  2. 9 core/modules/image/tests/src/Kernel/ImageStyleCustomStreamWrappersTest.php \Drupal\Tests\image\Kernel\ImageStyleCustomStreamWrappersTest::testCustomStreamWrappers()

Tests derivative creation with several source on a local writable stream.

@dataProvider providerTestCustomStreamWrappers

Parameters

string $source_scheme: The source stream wrapper scheme.

string $expected_scheme: The derivative expected stream wrapper scheme.

File

core/modules/image/tests/src/Kernel/ImageStyleCustomStreamWrappersTest.php, line 77

Class

ImageStyleCustomStreamWrappersTest
Tests derivative generation with source images using stream wrappers.

Namespace

Drupal\Tests\image\Kernel

Code

public function testCustomStreamWrappers($source_scheme, $expected_scheme) {
  $derivative_uri = $this->imageStyle
    ->buildUri("{$source_scheme}://some/path/image.png");
  $derivative_scheme = StreamWrapperManager::getScheme($derivative_uri);

  // Check that the derivative scheme is the expected scheme.
  $this
    ->assertSame($expected_scheme, $derivative_scheme);

  // Check that the derivative URI is the expected one.
  $expected_uri = "{$expected_scheme}://styles/{$this->imageStyle->id()}/{$source_scheme}/some/path/image.png";
  $this
    ->assertSame($expected_uri, $derivative_uri);
}