You are here

public function FlysystemServiceProviderTest::test in Flysystem 3.0.x

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

@covers \Drupal\flysystem\FlysystemServiceProvider

File

tests/src/Unit/FlysystemServiceProviderTest.php, line 93

Class

FlysystemServiceProviderTest
@coversDefaultClass \Drupal\flysystem\FlysystemServiceProvider @group flysystem

Namespace

Drupal\Tests\flysystem\Unit

Code

public function test() {

  // Test swapping the asset dumper.
  $this->container
    ->register('asset.js.dumper', AssetDumper::class);
  (new FlysystemServiceProvider())
    ->register($this->container);
  $this
    ->assertSame(AssetDumper::class, $this->container
    ->getDefinition('asset.js.dumper')
    ->getClass());
  $this->container
    ->register('asset.js.collection_optimizer', JsCollectionOptimizer::class);
  (new FlysystemServiceProvider())
    ->register($this->container);
  $this
    ->assertSame(AssetDumper::class, $this->container
    ->getDefinition('asset.js.dumper')
    ->getClass());
  $this
    ->assertSame(JsCollectionOptimizer::class, $this->container
    ->getDefinition('asset.js.collection_optimizer')
    ->getClass());

  // A successful swap.
  new Settings([
    'flysystem' => [
      'testscheme' => [
        'driver' => 'whatever',
        'serve_js' => TRUE,
      ],
    ],
  ]);
  (new FlysystemServiceProvider())
    ->register($this->container);
  $this
    ->assertSame(FlysystemAssetDumper::class, $this->container
    ->getDefinition('asset.js.dumper')
    ->getClass());
  $this
    ->assertSame(FlysystemJsCollectionOptimizer::class, $this->container
    ->getDefinition('asset.js.collection_optimizer')
    ->getClass());
}