StreamWrapperManagerTest.php
Same filename and directory in other branches
- 11.x core/tests/Drupal/KernelTests/Core/StreamWrapper/StreamWrapperManagerTest.php
- 10 core/tests/Drupal/KernelTests/Core/StreamWrapper/StreamWrapperManagerTest.php
- 9 core/tests/Drupal/KernelTests/Core/StreamWrapper/StreamWrapperManagerTest.php
- 8.9.x core/tests/Drupal/KernelTests/Core/StreamWrapper/StreamWrapperManagerTest.php
Namespace
Drupal\KernelTests\Core\StreamWrapperFile
-
core/
tests/ Drupal/ KernelTests/ Core/ StreamWrapper/ StreamWrapperManagerTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\KernelTests\Core\StreamWrapper;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\KernelTests\KernelTestBase;
use Drupal\stream_wrapper_service_test\StreamWrapper\ServiceDependencyStreamWrapper;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
/**
* Tests Drupal\Core\StreamWrapper\StreamWrapperManager.
*/
class StreamWrapperManagerTest extends KernelTestBase {
/**
* Tests uri scheme.
*
* @legacy-covers ::getScheme
*/
public function testUriScheme($uri, $expected) : void {
$this->assertSame($expected, StreamWrapperManager::getScheme($uri));
}
/**
* Data provider.
*/
public static function providerTestUriScheme() : array {
$data = [];
$data[] = [
'public://filename',
'public',
];
$data[] = [
'public://extra://',
'public',
];
$data[] = [
'invalid',
FALSE,
];
return $data;
}
/**
* Tests installing a module providing a stream wrapper using services.
*/
public function testModuleInstallRegistration() : void {
$this->container
->get('stream_wrapper_manager')
->register();
$this->container
->get('module_installer')
->install([
'stream_wrapper_service_test',
]);
$manager = \Drupal::service('stream_wrapper_manager');
$this->assertSame(ServiceDependencyStreamWrapper::class, $manager->getClass('test'));
$wrapper = $manager->getViaScheme('test');
$this->assertInstanceOf(ServiceDependencyStreamWrapper::class, $wrapper);
$this->assertSame($manager, $wrapper->streamWrapperManager);
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| StreamWrapperManagerTest | Tests Drupal\Core\StreamWrapper\StreamWrapperManager. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.