/**
* Tests the scheme functions.
*/
public function testGetValidStreamScheme() { /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
$stream_wrapper_manager = \Drupal::
service('stream_wrapper_manager'
);
$this->
assertEquals('foo',
$stream_wrapper_manager::
getScheme('foo://pork//chops'
), 'Got the correct scheme from foo://asdf'
);
$this->
assertEquals('data',
$stream_wrapper_manager::
getScheme('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
), 'Got the correct scheme from a data URI.'
);
$this->
assertFalse($stream_wrapper_manager::
getScheme('foo/bar.txt'
), 'foo/bar.txt is not a valid stream.'
);
$this->
assertTrue($stream_wrapper_manager->
isValidScheme($stream_wrapper_manager::
getScheme('public://asdf'
)), 'Got a valid stream scheme from public://asdf'
);
$this->
assertFalse($stream_wrapper_manager->
isValidScheme($stream_wrapper_manager::
getScheme('foo://asdf'
)), 'Did not get a valid stream scheme from foo://asdf'
);
}}