|
| 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\Flysystem\WebDAV\WebDAVAdapter; |
| 16 | +use League\FlysystemBundle\Adapter\Builder\WebDAVAdapterDefinitionBuilder; |
| 17 | +use PHPUnit\Framework\TestCase; |
| 18 | + |
| 19 | +/** |
| 20 | + * @author Kévin Dunglas <[email protected]> |
| 21 | + */ |
| 22 | +class WebDAVAdapterDefinitionBuilderTest extends TestCase |
| 23 | +{ |
| 24 | + public function createBuilder(): WebDAVAdapterDefinitionBuilder |
| 25 | + { |
| 26 | + return new WebDAVAdapterDefinitionBuilder(); |
| 27 | + } |
| 28 | + |
| 29 | + public static function provideValidOptions(): \Generator |
| 30 | + { |
| 31 | + yield 'minimal' => [[ |
| 32 | + 'client' => 'webdav_client', |
| 33 | + ]]; |
| 34 | + |
| 35 | + yield 'full' => [[ |
| 36 | + 'client' => 'webdav_client', |
| 37 | + 'prefix' => 'optional/path/prefix', |
| 38 | + 'visibility_handling' => WebDAVAdapter::ON_VISIBILITY_THROW_ERROR, |
| 39 | + 'manual_copy' => false, |
| 40 | + 'manual_move' => false, |
| 41 | + ]]; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @dataProvider provideValidOptions |
| 46 | + */ |
| 47 | + public function testCreateDefinition(array $options): void |
| 48 | + { |
| 49 | + $this->assertSame(WebDAVAdapter::class, $this->createBuilder()->createDefinition($options, null)->getClass()); |
| 50 | + } |
| 51 | + |
| 52 | + public function testOptionsBehavior(): void |
| 53 | + { |
| 54 | + $definition = $this->createBuilder()->createDefinition([ |
| 55 | + 'client' => 'webdav_client', |
| 56 | + 'prefix' => 'optional/path/prefix', |
| 57 | + 'visibility_handling' => WebDAVAdapter::ON_VISIBILITY_IGNORE, |
| 58 | + 'manual_copy' => false, |
| 59 | + 'manual_move' => false, |
| 60 | + ], Visibility::PUBLIC); |
| 61 | + |
| 62 | + $this->assertSame(WebDAVAdapter::class, $definition->getClass()); |
| 63 | + $this->assertSame('webdav_client', (string) $definition->getArgument(0)); |
| 64 | + $this->assertSame('optional/path/prefix', $definition->getArgument(1)); |
| 65 | + $this->assertSame(WebDAVAdapter::ON_VISIBILITY_IGNORE, $definition->getArgument(2)); |
| 66 | + $this->assertFalse($definition->getArgument(3)); |
| 67 | + $this->assertFalse($definition->getArgument(4)); |
| 68 | + } |
| 69 | +} |
0 commit comments