You are here

public function StreamWrapperTest::testGetValidStreamScheme in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php \Drupal\KernelTests\Core\File\StreamWrapperTest::testGetValidStreamScheme()

Test the scheme functions.

File

core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php, line 145

Class

StreamWrapperTest
Tests stream wrapper functions.

Namespace

Drupal\KernelTests\Core\File

Code

public function testGetValidStreamScheme() {

  /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
  $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
  $this
    ->assertEqual('foo', $stream_wrapper_manager::getScheme('foo://pork//chops'), 'Got the correct scheme from foo://asdf');
  $this
    ->assertEqual('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');
}