public function StreamWrapperTest::testPharStreamWrapperRegistration in Drupal 7
Tests that phar stream wrapper is registered as expected.
See also
File
- modules/
simpletest/ tests/ file.test, line 2985 - This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.
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();
}