function StreamWrapperTest::testPharStreamWrapperRegistration
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php \Drupal\KernelTests\Core\File\StreamWrapperTest::testPharStreamWrapperRegistration()
- 8.9.x core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php \Drupal\KernelTests\Core\File\StreamWrapperTest::testPharStreamWrapperRegistration()
Tests that phar stream wrapper is registered as expected.
See also
File
-
modules/
simpletest/ tests/ file.test, line 3062
Class
- StreamWrapperTest
- Tests stream wrapper functions.
Code
public function testPharStreamWrapperRegistration() {
if (!class_exists('Phar', FALSE)) {
$this->assertFalse(in_array('phar', stream_get_wrappers(), TRUE), 'PHP is compiled without phar support. Therefore, no phar stream wrapper is registered.');
}
elseif (version_compare(PHP_VERSION, '5.3.3', '<')) {
$this->assertFalse(in_array('phar', stream_get_wrappers(), TRUE), 'The PHP version is <5.3.3. The built-in phar stream wrapper has been unregistered and not replaced.');
}
else {
$this->assertTrue(in_array('phar', stream_get_wrappers(), TRUE), 'A phar stream wrapper is registered.');
$this->assertFalse(file_stream_wrapper_valid_scheme('phar'), 'The phar scheme is not a valid scheme for Drupal File API usage.');
}
// Ensure that calling file_get_stream_wrappers() multiple times, both
// without and with a drupal_static_reset() in between, does not create
// errors due to the PharStreamWrapperManager singleton.
file_get_stream_wrappers();
file_get_stream_wrappers();
drupal_static_reset('file_get_stream_wrappers');
file_get_stream_wrappers();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.