|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the flysystem-bundle project. |
| 5 | + * |
| 6 | + * (c) Titouan Galopin <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Tests\League\FlysystemBundle\Adapter\Builder; |
| 13 | + |
| 14 | +use League\Flysystem\Visibility; |
| 15 | +use League\FlysystemBundle\Adapter\Builder\BunnyCDNAdapterDefinitionBuilder; |
| 16 | +use PHPUnit\Framework\TestCase; |
| 17 | +use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter; |
| 18 | + |
| 19 | +class BunnyCDNAdapterDefinitionBuilderTest extends TestCase |
| 20 | +{ |
| 21 | + public function createBuilder(): BunnyCDNAdapterDefinitionBuilder |
| 22 | + { |
| 23 | + return new BunnyCDNAdapterDefinitionBuilder(); |
| 24 | + } |
| 25 | + |
| 26 | + public static function provideValidOptions(): \Generator |
| 27 | + { |
| 28 | + yield 'minimal' => [[ |
| 29 | + 'client' => 'bunny_client', |
| 30 | + ]]; |
| 31 | + |
| 32 | + yield 'full' => [[ |
| 33 | + 'client' => 'bunny_client', |
| 34 | + 'pull_zone' => 'z1', |
| 35 | + ]]; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @dataProvider provideValidOptions |
| 40 | + */ |
| 41 | + public function testCreateDefinition(array $options): void |
| 42 | + { |
| 43 | + $this->assertSame(BunnyCDNAdapter::class, $this->createBuilder()->createDefinition($options, null)->getClass()); |
| 44 | + } |
| 45 | + |
| 46 | + public function testOptionsBehavior(): void |
| 47 | + { |
| 48 | + $definition = $this->createBuilder()->createDefinition([ |
| 49 | + 'client' => 'bunny_client', |
| 50 | + 'pull_zone' => 'z1', |
| 51 | + ], Visibility::PUBLIC); |
| 52 | + |
| 53 | + $this->assertSame(BunnyCDNAdapter::class, $definition->getClass()); |
| 54 | + $this->assertSame('bunny_client', (string) $definition->getArgument(0)); |
| 55 | + $this->assertSame('z1', $definition->getArgument(1)); |
| 56 | + } |
| 57 | +} |
0 commit comments