|
18 | 18 | use League\Flysystem\Filesystem; |
19 | 19 | use League\Flysystem\FilesystemOperator; |
20 | 20 | use League\Flysystem\UnableToWriteFile; |
| 21 | +use League\FlysystemBundle\Adapter\Builder\AdapterDefinitionBuilderInterface; |
| 22 | +use League\FlysystemBundle\DependencyInjection\FlysystemExtension; |
21 | 23 | use MicrosoftAzure\Storage\Blob\BlobRestProxy; |
22 | 24 | use PHPUnit\Framework\TestCase; |
| 25 | +use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
| 26 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 27 | +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
23 | 28 | use Symfony\Component\Dotenv\Dotenv; |
24 | 29 | use Tests\League\FlysystemBundle\Kernel\FlysystemAppKernel; |
25 | 30 |
|
@@ -137,6 +142,48 @@ public function testNotRetainingVisibilityPreventsAclCommandInvocation(): void |
137 | 142 | self::assertFalse($calledGetObjectAcl, 'The ACL command should not be called when `retain_visibility` is set to `false`.'); |
138 | 143 | } |
139 | 144 |
|
| 145 | + public function testPrependCallsPrependOnBuildersThatImplementIt(): void |
| 146 | + { |
| 147 | + $container = new ContainerBuilder(); |
| 148 | + $prepended = false; |
| 149 | + |
| 150 | + $builder = new class($prepended) implements AdapterDefinitionBuilderInterface, PrependExtensionInterface { |
| 151 | + public function __construct(private bool &$prepended) |
| 152 | + { |
| 153 | + } |
| 154 | + |
| 155 | + public function getName(): string |
| 156 | + { |
| 157 | + return 'test'; |
| 158 | + } |
| 159 | + |
| 160 | + public function getRequiredPackages(): array |
| 161 | + { |
| 162 | + return []; |
| 163 | + } |
| 164 | + |
| 165 | + public function addConfiguration(NodeDefinition $node): void |
| 166 | + { |
| 167 | + } |
| 168 | + |
| 169 | + public function createAdapter(ContainerBuilder $container, string $storageName, array $options, ?string $defaultVisibilityForDirectories): ?string |
| 170 | + { |
| 171 | + return null; |
| 172 | + } |
| 173 | + |
| 174 | + public function prepend(ContainerBuilder $container): void |
| 175 | + { |
| 176 | + $this->prepended = true; |
| 177 | + } |
| 178 | + }; |
| 179 | + |
| 180 | + $extension = new FlysystemExtension(); |
| 181 | + $extension->addAdapterDefinitionBuilder($builder); |
| 182 | + $extension->prepend($container); |
| 183 | + |
| 184 | + $this->assertTrue($prepended); |
| 185 | + } |
| 186 | + |
140 | 187 | private function createFlysystemKernel(): FlysystemAppKernel |
141 | 188 | { |
142 | 189 | (new Dotenv())->populate([ |
|
0 commit comments