class FlysystemServiceProviderTest in Flysystem 8
Same name and namespace in other branches
- 3.x tests/src/Unit/FlysystemServiceProviderTest.php \Drupal\Tests\flysystem\Unit\FlysystemServiceProviderTest
- 2.0.x tests/src/Unit/FlysystemServiceProviderTest.php \Drupal\Tests\flysystem\Unit\FlysystemServiceProviderTest
- 3.0.x tests/src/Unit/FlysystemServiceProviderTest.php \Drupal\Tests\flysystem\Unit\FlysystemServiceProviderTest
@coversDefaultClass \Drupal\flysystem\FlysystemServiceProvider @group flysystem
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\flysystem\Unit\FlysystemServiceProviderTest
Expanded class hierarchy of FlysystemServiceProviderTest
File
- tests/
src/ Unit/ FlysystemServiceProviderTest.php, line 24
Namespace
Drupal\Tests\flysystem\UnitView source
class FlysystemServiceProviderTest extends UnitTestCase {
/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* {@inheritdoc}
*/
public function setUp() {
$this->container = new ContainerBuilder();
}
/**
* @covers ::register
*/
public function testNothingFailsIfContainerIsEmpty() {
new Settings([]);
(new FlysystemServiceProvider())
->register($this->container);
}
/**
* @covers ::register
*/
public function testMissingDriverIsSkipped() {
new Settings([
'flysystem' => [
'testscheme' => [],
],
]);
(new FlysystemServiceProvider())
->register($this->container);
$this
->assertFalse($this->container
->has('flysystem_stream_wrapper.testscheme'));
}
/**
* @covers ::register
*/
public function testValidSchemeConfiguration() {
new Settings([
'flysystem' => [
'testscheme' => [
'driver' => 'whatever',
],
],
]);
(new FlysystemServiceProvider())
->register($this->container);
$this
->assertTrue($this->container
->has('flysystem_stream_wrapper.testscheme'));
$this
->assertSame(FlysystemBridge::class, $this->container
->getDefinition('flysystem_stream_wrapper.testscheme')
->getClass());
$this
->assertSame([
[
'scheme' => 'testscheme',
],
], $this->container
->getDefinition('flysystem_stream_wrapper.testscheme')
->getTag('stream_wrapper'));
}
/**
* @covers ::register
*/
public function testLocalRouteProviderGetsAdded() {
new Settings([
'flysystem' => [
'testscheme' => [
'driver' => 'local',
'config' => [
'public' => TRUE,
],
],
],
]);
(new FlysystemServiceProvider())
->register($this->container);
$this
->assertSame(LocalPathProcessor::class, $this->container
->getDefinition('flysystem.testscheme.path_processor')
->getClass());
}
/**
* @covers \Drupal\flysystem\FlysystemServiceProvider
*/
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());
}
/**
* @covers \Drupal\flysystem\FlysystemServiceProvider
*/
public function testSwappingCssServices() {
// Test swapping the asset dumper.
$this->container
->register('asset.css.dumper', AssetDumper::class);
$this->container
->register('asset.css.collection_optimizer', CssCollectionOptimizer::class);
$this->container
->register('asset.css.optimizer', CssOptimizer::class);
new Settings([
'flysystem' => [
'testscheme' => [
'driver' => 'whatever',
'serve_css' => TRUE,
],
],
]);
(new FlysystemServiceProvider())
->register($this->container);
$this
->assertSame(FlysystemAssetDumper::class, $this->container
->getDefinition('asset.css.dumper')
->getClass());
$this
->assertSame(FlysystemCssCollectionOptimizer::class, $this->container
->getDefinition('asset.css.collection_optimizer')
->getClass());
$this
->assertSame(FlysystemCssOptimizer::class, $this->container
->getDefinition('asset.css.optimizer')
->getClass());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlysystemServiceProviderTest:: |
protected | property | ||
FlysystemServiceProviderTest:: |
public | function |
Overrides UnitTestCase:: |
|
FlysystemServiceProviderTest:: |
public | function | @covers \Drupal\flysystem\FlysystemServiceProvider | |
FlysystemServiceProviderTest:: |
public | function | @covers ::register | |
FlysystemServiceProviderTest:: |
public | function | @covers ::register | |
FlysystemServiceProviderTest:: |
public | function | @covers ::register | |
FlysystemServiceProviderTest:: |
public | function | @covers \Drupal\flysystem\FlysystemServiceProvider | |
FlysystemServiceProviderTest:: |
public | function | @covers ::register | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |