You are here

public function ModuleFunctionsTest::setUp in Flysystem 8

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

Overrides UnitTestCase::setUp

File

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

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(FileSystemInterface::class);
  $file_system_helper
    ->uriScheme(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);
}