-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from nspyke/v3
Version 3
- Loading branch information
Showing
15 changed files
with
229 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create()->in(__DIR__); | ||
$config = new PhpCsFixer\Config(); | ||
|
||
return $config->setRules([ | ||
'@Symfony' => true, | ||
'phpdoc_annotation_without_dot' => false, | ||
]) | ||
->setFinder($finder); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the flysystem-bundle project. | ||
* | ||
* (c) Titouan Galopin <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace League\FlysystemBundle\Adapter\Builder; | ||
|
||
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @author Titouan Galopin <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
class AzureAdapterDefinitionBuilder extends AbstractAdapterDefinitionBuilder | ||
{ | ||
public function getName(): string | ||
{ | ||
return 'azure'; | ||
} | ||
|
||
protected function getRequiredPackages(): array | ||
{ | ||
return [ | ||
AzureBlobStorageAdapter::class => 'league/flysystem-azure-blob-storage', | ||
]; | ||
} | ||
|
||
protected function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver->setRequired('client'); | ||
$resolver->setAllowedTypes('client', 'string'); | ||
|
||
$resolver->setRequired('container'); | ||
$resolver->setAllowedTypes('container', 'string'); | ||
|
||
$resolver->setDefault('prefix', ''); | ||
$resolver->setAllowedTypes('prefix', 'string'); | ||
} | ||
|
||
protected function configureDefinition(Definition $definition, array $options) | ||
{ | ||
$definition->setClass(AzureBlobStorageAdapter::class); | ||
$definition->setArgument(0, new Reference($options['client'])); | ||
$definition->setArgument(1, $options['container']); | ||
$definition->setArgument(2, $options['prefix']); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
tests/Adapter/Builder/AzureAdapterDefinitionBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the flysystem-bundle project. | ||
* | ||
* (c) Titouan Galopin <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\League\FlysystemBundle\Adapter\Builder; | ||
|
||
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter; | ||
use League\FlysystemBundle\Adapter\Builder\AzureAdapterDefinitionBuilder; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class AzureAdapterDefinitionBuilderTest extends TestCase | ||
{ | ||
public function createBuilder() | ||
{ | ||
return new AzureAdapterDefinitionBuilder(); | ||
} | ||
|
||
public function provideValidOptions() | ||
{ | ||
yield 'minimal' => [[ | ||
'client' => 'my_client', | ||
'container' => 'container_name', | ||
]]; | ||
|
||
yield 'prefix' => [[ | ||
'client' => 'my_client', | ||
'container' => 'container_name', | ||
'prefix' => 'prefix/path', | ||
]]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideValidOptions | ||
*/ | ||
public function testCreateDefinition($options) | ||
{ | ||
$this->assertSame(AzureBlobStorageAdapter::class, $this->createBuilder()->createDefinition($options)->getClass()); | ||
} | ||
|
||
public function testOptionsBehavior() | ||
{ | ||
$definition = $this->createBuilder()->createDefinition([ | ||
'client' => 'my_client', | ||
'container' => 'container_name', | ||
'prefix' => 'prefix/path', | ||
]); | ||
|
||
$this->assertSame(AzureBlobStorageAdapter::class, $definition->getClass()); | ||
$this->assertInstanceOf(Reference::class, $definition->getArgument(0)); | ||
$this->assertSame('my_client', (string) $definition->getArgument(0)); | ||
$this->assertSame('container_name', $definition->getArgument(1)); | ||
$this->assertSame('prefix/path', $definition->getArgument(2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.