function ExtensionStreamTest::testStreamWrapperMethods

Tests the extension stream wrapper methods.

Attributes

#[TestWith([ 'module://system/css/system.admin.css', 'module://system/css', 'core/modules/system/css/system.admin.css', ])] #[TestWith([ 'module://image/sample.png', 'module://image', 'core/modules/image/sample.png', ])] #[TestWith([ 'theme://claro/style.css', 'theme://claro', 'core/themes/claro/style.css', ])] #[TestWith([ 'theme://olivero/js/checkbox.js', 'theme://olivero/js', 'core/themes/olivero/js/checkbox.js', ])]

Parameters

string $uri: The uri to be tested.

string $expected_dirname: Expected result of calling the dirname() method.

string $expected_path: Path added to the base URL and extension's directory to test the realpath() and getExternalUrl() methods.

File

core/tests/Drupal/KernelTests/Core/StreamWrapper/ExtensionStreamTest.php, line 111

Class

ExtensionStreamTest
Tests extension stream wrappers.

Namespace

Drupal\KernelTests\Core\StreamWrapper

Code

public function testStreamWrapperMethods(string $uri, string $expected_dirname, string $expected_path) : void {
  $base_url = $this->container
    ->get('router.request_context')
    ->getCompleteBaseUrl();
  $this->enableModules([
    'image',
  ]);
  [$scheme] = explode('://', $uri);
  $this->streamWrappers[$scheme]
    ->setUri($uri);
  $this->assertSame($expected_dirname, $this->streamWrappers[$scheme]
    ->dirname());
  $this->assertSame($this->root . '/' . $expected_path, $this->streamWrappers[$scheme]
    ->realpath());
  $this->assertSame($base_url . '/' . $expected_path, $this->streamWrappers[$scheme]
    ->getExternalUrl());
}

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