You are here

public function ModuleFunctionsTest::setUp in Flysystem 3.0.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/ModuleFunctionsTest.php \Drupal\Tests\flysystem\Unit\ModuleFunctionsTest::setUp()
  2. 3.x tests/src/Unit/ModuleFunctionsTest.php \Drupal\Tests\flysystem\Unit\ModuleFunctionsTest::setUp()
  3. 2.0.x tests/src/Unit/ModuleFunctionsTest.php \Drupal\Tests\flysystem\Unit\ModuleFunctionsTest::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/ModuleFunctionsTest.php, line 30

Class

ModuleFunctionsTest
Tests module functions.

Namespace

Drupal\Tests\flysystem\Unit

Code

public function setUp() {
  parent::setUp();
  vfsStream::setup('module_file');
  require_once dirname(dirname(dirname(__DIR__))) . '/flysystem.module';
  $this->factory = $this
    ->prophesize(FlysystemFactory::class);
  $this->factory
    ->getSchemes()
    ->willReturn([
    'vfs',
  ]);
  $file_system_helper = $this
    ->prophesize(StreamWrapperManagerInterface::class);
  $file_system_helper
    ->isValidScheme(Argument::type('string'))
    ->will(function ($uri) {
    list($scheme) = explode('://', $uri[0]);
    return $scheme;
  });
  $guesser = $this
    ->prophesize(MimeTypeGuesserInterface::class);
  $guesser
    ->guess(Argument::type('string'))
    ->willReturn('txt/flysystem');
  $container = new ContainerBuilder();
  $container
    ->set('file_system', $file_system_helper
    ->reveal());
  $container
    ->set('flysystem_factory', $this->factory
    ->reveal());
  $container
    ->set('file.mime_type.guesser.extension', $guesser
    ->reveal());
  \Drupal::setContainer($container);
}