|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * This file is part of the flysystem-bundle project. |
| 4 | + * |
| 5 | + * (c) Titouan Galopin <galopintitouan@gmail.com> |
| 6 | + * |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
| 9 | + */ |
| 10 | + |
| 11 | +namespace Tests\League\FlysystemBundle\Adapter\Builder; |
| 12 | + |
| 13 | +use League\FlysystemBundle\Adapter\Builder\CacheAdapterDefinitionBuilder; |
| 14 | +use Lustmored\Flysystem\Cache\CacheAdapter; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | +use Symfony\Component\DependencyInjection\Reference; |
| 17 | + |
| 18 | +class CacheAdapterDefinitionBuilderTest extends TestCase |
| 19 | +{ |
| 20 | + public function createBuilder() |
| 21 | + { |
| 22 | + return new CacheAdapterDefinitionBuilder(); |
| 23 | + } |
| 24 | + |
| 25 | + public function provideValidOptions() |
| 26 | + { |
| 27 | + yield 'minimal' => [[ |
| 28 | + 'store' => 'my_store', |
| 29 | + 'source' => 'my_source', |
| 30 | + ]]; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @dataProvider provideValidOptions |
| 35 | + */ |
| 36 | + public function testCreateDefinition($options) |
| 37 | + { |
| 38 | + $this->assertSame(CacheAdapter::class, $this->createBuilder()->createDefinition($options)->getClass()); |
| 39 | + } |
| 40 | + |
| 41 | + public function testOptionsBehavior() |
| 42 | + { |
| 43 | + $definition = $this->createBuilder()->createDefinition([ |
| 44 | + 'store' => 'my_store', |
| 45 | + 'source' => 'my_source', |
| 46 | + ]); |
| 47 | + |
| 48 | + $this->assertSame(CacheAdapter::class, $definition->getClass()); |
| 49 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 50 | + $this->assertSame('flysystem.adapter.my_source', (string) $definition->getArgument(0)); |
| 51 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(1)); |
| 52 | + $this->assertSame('my_store', (string) $definition->getArgument(1)); |
| 53 | + } |
| 54 | +} |
0 commit comments