public function ModuleHandlerTest::testModuleStreamWrappers in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testModuleStreamWrappers()
- 10 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testModuleStreamWrappers()
Tests whether module-provided stream wrappers are registered properly.
File
- core/
modules/ system/ tests/ src/ Kernel/ Extension/ ModuleHandlerTest.php, line 308
Class
- ModuleHandlerTest
- Tests ModuleHandler functionality.
Namespace
Drupal\Tests\system\Kernel\ExtensionCode
public function testModuleStreamWrappers() {
// file_test.module provides (among others) a 'dummy' stream wrapper.
// Verify that it is not registered yet to prevent false positives.
$stream_wrappers = \Drupal::service('stream_wrapper_manager')
->getWrappers();
$this
->assertFalse(isset($stream_wrappers['dummy']));
$this
->moduleInstaller()
->install([
'file_test',
]);
// Verify that the stream wrapper is available even without calling
// \Drupal::service('stream_wrapper_manager')->getWrappers() again.
// If the stream wrapper is not available file_exists() will raise a notice.
file_exists('dummy://');
$stream_wrappers = \Drupal::service('stream_wrapper_manager')
->getWrappers();
$this
->assertTrue(isset($stream_wrappers['dummy']));
}