From 26a36f323d46e11639f84e50d3f60f820882f2c5 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 27 Dec 2023 18:34:57 +0100 Subject: [PATCH 1/3] Upgrade to league/flysystem v3 # Conflicts: # src/Factories/AzureFactory.php # src/Factories/FtpFactory.php # src/Factories/LocalFactory.php # src/Factories/RackspaceFactory.php # src/Factories/ReplicateFactory.php # src/Factories/SftpFactory.php # tests/TestCase/Storage/Factories/AbstractFactoryTest.php --- README.md | 1 + composer.json | 20 +- phpstan.neon | 1 - src/Adapter/NullFilesystemAdapter.php | 188 ++++++++++++++++++ src/Factories/AbstractFactory.php | 8 +- src/Factories/AwsS3v3Factory.php | 10 +- src/Factories/AzureFactory.php | 6 +- src/Factories/DropboxFactory.php | 4 +- src/Factories/FactoryInterface.php | 6 +- src/Factories/FtpFactory.php | 57 ------ src/Factories/LocalFactory.php | 13 +- src/Factories/MemoryFactory.php | 10 +- src/Factories/NullFactory.php | 11 +- src/Factories/RackspaceFactory.php | 68 ------- src/Factories/ReplicateFactory.php | 59 ------ src/Factories/SftpFactory.php | 52 ----- src/Factories/WebDAVFactory.php | 4 +- src/Factories/ZipArchiveFactory.php | 4 +- src/StorageAdapterFactory.php | 6 +- src/StorageAdapterFactoryInterface.php | 6 +- .../Storage/Factories/AbstractFactoryTest.php | 9 +- 21 files changed, 245 insertions(+), 298 deletions(-) create mode 100644 src/Adapter/NullFilesystemAdapter.php delete mode 100644 src/Factories/FtpFactory.php delete mode 100644 src/Factories/RackspaceFactory.php delete mode 100644 src/Factories/ReplicateFactory.php delete mode 100644 src/Factories/SftpFactory.php diff --git a/README.md b/README.md index a7738b9..eebbfa1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Storage Factories for Flysystem +[![CI](https://github.com/php-collective/file-storage-factories/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/php-collective/file-storage-factories/actions/workflows/ci.yml) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) In the underlying Flysystem implementation some adapters are more or less complex to build. Sometimes you have to compose multiple objects and feed them to an adapter. The factories take this burden away from you and provide you the same interface for all adapters. Just their config array options differ. diff --git a/composer.json b/composer.json index 8b96bac..831cea4 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "prefer-stable": true, "require": { "php": ">=8.1", - "league/flysystem": "^1.0", + "league/flysystem": "^3.22", "psr/container": "^1.0|^2.0" }, "require-dev": { @@ -38,17 +38,13 @@ "phpstan/phpstan": "^1.10", "php-collective/code-sniffer": "^0.2.1", "instituteweb/composer-scripts": "^1.1", - "league/flysystem-aws-s3-v3": "^1.0.29", - "league/flysystem-azure": "^1.0", - "league/flysystem-azure-blob-storage": "^1.0", - "league/flysystem-gridfs": "^1.0", - "league/flysystem-memory": "^1.0", - "league/flysystem-rackspace": "^1.0", - "league/flysystem-replicate-adapter": "^1.0", - "league/flysystem-sftp": "^1.0", - "league/flysystem-webdav": "^1.0", - "league/flysystem-ziparchive": "^1.0", - "spatie/flysystem-dropbox": "^1.2" + "league/flysystem-aws-s3-v3": "^3.22", + "league/flysystem-azure-blob-storage": "^3.22", + "league/flysystem-memory": "^3.0", + "league/flysystem-sftp": "^3.22", + "league/flysystem-webdav": "^3.21", + "league/flysystem-ziparchive": "^3.21", + "spatie/flysystem-dropbox": "^3.0.1" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index b8ac19b..20fd46b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,4 +5,3 @@ parameters: checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false ignoreErrors: - - '#Call to an undefined static method .+BlobRestProxy::createBlobService\(\).#' diff --git a/src/Adapter/NullFilesystemAdapter.php b/src/Adapter/NullFilesystemAdapter.php new file mode 100644 index 0000000..630aff1 --- /dev/null +++ b/src/Adapter/NullFilesystemAdapter.php @@ -0,0 +1,188 @@ + null, @@ -41,18 +40,17 @@ class AwsS3v3Factory extends AbstractFactory /** * @inheritDoc */ - public function build(array $config): AdapterInterface + public function build(array $config): AwsS3V3Adapter { $this->availabilityCheck(); $config += $this->defaults; - return new AwsS3Adapter( + return new AwsS3V3Adapter( S3Client::factory( $config['client'], ), $config['bucket'], $config['prefix'], - $config, ); } } diff --git a/src/Factories/AzureFactory.php b/src/Factories/AzureFactory.php index 75811d6..e3b9c76 100644 --- a/src/Factories/AzureFactory.php +++ b/src/Factories/AzureFactory.php @@ -14,8 +14,8 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\AdapterInterface; use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter; +use League\Flysystem\FilesystemAdapter; use MicrosoftAzure\Storage\Blob\BlobRestProxy; use PhpCollective\Infrastructure\Storage\Factories\Exception\FactoryConfigException; @@ -40,7 +40,7 @@ class AzureFactory extends AbstractFactory /** * @inheritDoc */ - public function build($config): AdapterInterface + public function build($config): FilesystemAdapter { $this->availabilityCheck(); $this->checkConfig($config); @@ -57,7 +57,7 @@ public function build($config): AdapterInterface } /** - * @param array $config + * @param array $config * * @throws \PhpCollective\Infrastructure\Storage\Factories\Exception\FactoryConfigException * diff --git a/src/Factories/DropboxFactory.php b/src/Factories/DropboxFactory.php index f1d67a8..6902cf7 100644 --- a/src/Factories/DropboxFactory.php +++ b/src/Factories/DropboxFactory.php @@ -14,7 +14,7 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; use Spatie\Dropbox\Client; use Spatie\FlysystemDropbox\DropboxAdapter; @@ -36,7 +36,7 @@ class DropboxFactory extends AbstractFactory /** * @inheritDoc */ - public function build(array $config): AdapterInterface + public function build(array $config): FilesystemAdapter { $config += $this->defaults; $client = new Client($config['authToken']); diff --git a/src/Factories/FactoryInterface.php b/src/Factories/FactoryInterface.php index 23eb090..f68f760 100644 --- a/src/Factories/FactoryInterface.php +++ b/src/Factories/FactoryInterface.php @@ -14,7 +14,7 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; /** * Factory Interface @@ -34,9 +34,9 @@ public function alias(): string; /** * @param array $config * - * @return \League\Flysystem\AdapterInterface + * @return \League\Flysystem\FilesystemAdapter */ - public function build(array $config): AdapterInterface; + public function build(array $config): FilesystemAdapter; /** * @return void diff --git a/src/Factories/FtpFactory.php b/src/Factories/FtpFactory.php deleted file mode 100644 index 8950491..0000000 --- a/src/Factories/FtpFactory.php +++ /dev/null @@ -1,57 +0,0 @@ - '', - 'username' => '', - 'password' => '', - // Optional settings - 'port' => 21, - 'root' => '/', - 'passive' => true, - 'ssl' => true, - 'timeout' => 30, - 'ignorePassiveAddress' => false, - ]; - - /** - * @inheritDoc - */ - public function build(array $config): AdapterInterface - { - if (!defined('FTP_BINARY')) { - define('FTP_BINARY', 'ftp.exe'); - } - - $config += $this->defaults; - - return new Ftp($config); - } -} diff --git a/src/Factories/LocalFactory.php b/src/Factories/LocalFactory.php index 6f10d65..133eb20 100644 --- a/src/Factories/LocalFactory.php +++ b/src/Factories/LocalFactory.php @@ -14,8 +14,7 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\Adapter\Local; -use League\Flysystem\AdapterInterface; +use League\Flysystem\Local\LocalFilesystemAdapter; /** * LocalFactory @@ -26,19 +25,19 @@ class LocalFactory extends AbstractFactory protected string $package = 'league/flysystem'; - protected string $className = Local::class; + protected string $className = LocalFilesystemAdapter::class; /** - * @param array $config + * @param array $config * - * @return \League\Flysystem\AdapterInterface + * @return \League\Flysystem\Local\LocalFilesystemAdapter */ - public function build(array $config): AdapterInterface + public function build(array $config): LocalFilesystemAdapter { $this->availabilityCheck(); $config += ['root' => '/']; - return new Local($config['root']); + return new LocalFilesystemAdapter($config['root']); } } diff --git a/src/Factories/MemoryFactory.php b/src/Factories/MemoryFactory.php index b5b080c..bcd3bbf 100644 --- a/src/Factories/MemoryFactory.php +++ b/src/Factories/MemoryFactory.php @@ -14,8 +14,8 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\AdapterInterface; -use League\Flysystem\Memory\MemoryAdapter; +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\InMemory\InMemoryFilesystemAdapter; /** * Memory @@ -26,13 +26,13 @@ class MemoryFactory extends AbstractFactory protected string $package = 'league/flysystem-memory'; - protected string $className = MemoryAdapter::class; + protected string $className = InMemoryFilesystemAdapter::class; /** * @inheritDoc */ - public function build(array $config): AdapterInterface + public function build(array $config): FilesystemAdapter { - return new MemoryAdapter(); + return new InMemoryFilesystemAdapter(); } } diff --git a/src/Factories/NullFactory.php b/src/Factories/NullFactory.php index 7ae8ee1..8436216 100644 --- a/src/Factories/NullFactory.php +++ b/src/Factories/NullFactory.php @@ -14,9 +14,8 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\Adapter\NullAdapter; -use League\Flysystem\AdapterInterface; -use League\Flysystem\AwsS3v3\AwsS3Adapter; +use League\Flysystem\FilesystemAdapter; +use PhpCollective\Infrastructure\Storage\Adapter\NullFilesystemAdapter; /** * NullFactory @@ -25,13 +24,13 @@ class NullFactory extends AbstractFactory { protected string $alias = 'null'; - protected string $className = AwsS3Adapter::class; + protected string $className = NullFilesystemAdapter::class; /** * @inheritDoc */ - public function build(array $config): AdapterInterface + public function build(array $config): FilesystemAdapter { - return new NullAdapter(); + return new NullFilesystemAdapter(); } } diff --git a/src/Factories/RackspaceFactory.php b/src/Factories/RackspaceFactory.php deleted file mode 100644 index 2864f36..0000000 --- a/src/Factories/RackspaceFactory.php +++ /dev/null @@ -1,68 +0,0 @@ - Rackspace::UK_IDENTITY_ENDPOINT, - 'username' => '', - 'apiKey' => '', - 'objectStoreService' => 'cloudFiles', - 'serviceRegion' => 'LON', - 'container' => 'flysystem', - 'serviceName' => 'cloudFiles', - ]; - - /** - * @inheritDoc - */ - public function build(array $config): AdapterInterface - { - $config += $this->defaults; - - $client = $this->buildClient($config); - $store = $client->objectStoreService($config['serviceName'], $config['serviceRegion']); - $container = $store->getContainer($config['container']); - - return new RackspaceAdapter($container); - } - - /** - * @param array $config Config - * - * @return \OpenCloud\Rackspace - */ - protected function buildClient(array $config): Rackspace - { - return new Rackspace($config['identityEndpoint'], [ - 'username' => $config['username'], - 'apiKey' => $config['apiKey'], - ]); - } -} diff --git a/src/Factories/ReplicateFactory.php b/src/Factories/ReplicateFactory.php deleted file mode 100644 index ac0a347..0000000 --- a/src/Factories/ReplicateFactory.php +++ /dev/null @@ -1,59 +0,0 @@ - '', - 'port' => 22, - 'username' => '', - 'password' => '', - 'privateKey' => '', - 'passphrase' => '', - 'root' => '/', - 'timeout' => 10, - 'directoryPerm' => 0755, - ]; - - /** - * @inheritDoc - */ - public function build(array $config): AdapterInterface - { - $config += $this->defaults; - - return new SftpAdapter($config); - } -} diff --git a/src/Factories/WebDAVFactory.php b/src/Factories/WebDAVFactory.php index cb83d20..45c5112 100644 --- a/src/Factories/WebDAVFactory.php +++ b/src/Factories/WebDAVFactory.php @@ -14,7 +14,7 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; use League\Flysystem\WebDAV\WebDAVAdapter; use Sabre\DAV\Client; @@ -39,7 +39,7 @@ class WebDAVFactory extends AbstractFactory /** * @inheritDoc */ - public function build(array $config): AdapterInterface + public function build(array $config): FilesystemAdapter { return new WebDAVAdapter(new Client($config)); } diff --git a/src/Factories/ZipArchiveFactory.php b/src/Factories/ZipArchiveFactory.php index 457299f..9350537 100644 --- a/src/Factories/ZipArchiveFactory.php +++ b/src/Factories/ZipArchiveFactory.php @@ -14,7 +14,7 @@ namespace PhpCollective\Infrastructure\Storage\Factories; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; use League\Flysystem\ZipArchive\ZipArchiveAdapter; /** @@ -31,7 +31,7 @@ class ZipArchiveFactory extends AbstractFactory /** * @inheritDoc */ - public function build(array $config): AdapterInterface + public function build(array $config): FilesystemAdapter { $defaults = [ 'location' => null, diff --git a/src/StorageAdapterFactory.php b/src/StorageAdapterFactory.php index 3489a01..aa621b7 100644 --- a/src/StorageAdapterFactory.php +++ b/src/StorageAdapterFactory.php @@ -14,7 +14,7 @@ namespace PhpCollective\Infrastructure\Storage; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; use PhpCollective\Infrastructure\Storage\Exception\AdapterFactoryNotFoundException; use Psr\Container\ContainerInterface; @@ -42,12 +42,12 @@ public function __construct(?ContainerInterface $container = null) * @param string $adapterClass Adapter alias or classname * @param array $options Options * - * @return \League\Flysystem\AdapterInterface + * @return \League\Flysystem\FilesystemAdapter */ public function buildStorageAdapter( string $adapterClass, array $options - ): AdapterInterface { + ): FilesystemAdapter { /** @var class-string<\PhpCollective\Infrastructure\Storage\Factories\FactoryInterface> $adapterClass */ $adapterClass = $this->checkAndResolveAdapterClass($adapterClass); diff --git a/src/StorageAdapterFactoryInterface.php b/src/StorageAdapterFactoryInterface.php index b91e8ba..47963bf 100644 --- a/src/StorageAdapterFactoryInterface.php +++ b/src/StorageAdapterFactoryInterface.php @@ -14,7 +14,7 @@ namespace PhpCollective\Infrastructure\Storage; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; /** * StorageFactory - Manages and instantiates storage engine adapters. @@ -27,10 +27,10 @@ interface StorageAdapterFactoryInterface * @param string $adapterClass Adapter alias or classname * @param array $options Options array * - * @return \League\Flysystem\AdapterInterface + * @return \League\Flysystem\FilesystemAdapter */ public function buildStorageAdapter( string $adapterClass, array $options - ): AdapterInterface; + ): FilesystemAdapter; } diff --git a/tests/TestCase/Storage/Factories/AbstractFactoryTest.php b/tests/TestCase/Storage/Factories/AbstractFactoryTest.php index 56bda4e..f4f51ab 100644 --- a/tests/TestCase/Storage/Factories/AbstractFactoryTest.php +++ b/tests/TestCase/Storage/Factories/AbstractFactoryTest.php @@ -14,7 +14,8 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; -use League\Flysystem\AdapterInterface; +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\Local\LocalFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Exception\PackageRequiredException; use PhpCollective\Infrastructure\Storage\Factories\AbstractFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; @@ -36,12 +37,14 @@ public function testFactory(): void /** * @param array $config * - * @return \League\Flysystem\AdapterInterface + * @return \League\Flysystem\FilesystemAdapter */ - public function build(array $config): AdapterInterface + public function build(array $config): FilesystemAdapter { $this->availabilityCheck(); + $testAdapter = LocalFilesystemAdapter::class; + return new $testAdapter(); } }; From 437953af77b3817aeef44cead5fc37c4f257e8c2 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 27 Dec 2023 18:42:48 +0100 Subject: [PATCH 2/3] FIx tests --- src/Factories/AwsS3v3Factory.php | 2 +- .../{WebDAVFactory.php => WebDavFactory.php} | 4 +- src/Factories/ZipArchiveFactory.php | 11 +++- .../Storage/Factories/AwsS3v3FactoryTest.php | 4 +- .../Storage/Factories/FtpFactoryTest.php | 35 ---------- .../Storage/Factories/LocalFactoryTest.php | 3 +- .../Storage/Factories/MemoryFactoryTest.php | 4 +- .../Storage/Factories/NullFactoryTest.php | 3 +- .../Factories/RackspaceFactoryTest.php | 53 --------------- .../Factories/ReplicateFactoryTest.php | 66 ------------------- .../Storage/Factories/SftpFactoryTest.php | 35 ---------- .../Storage/Factories/WebDavFactoryTest.php | 4 +- .../Storage/StorageAdapterFactoryTest.php | 3 +- 13 files changed, 23 insertions(+), 204 deletions(-) rename src/Factories/{WebDAVFactory.php => WebDavFactory.php} (94%) delete mode 100644 tests/TestCase/Storage/Factories/FtpFactoryTest.php delete mode 100644 tests/TestCase/Storage/Factories/RackspaceFactoryTest.php delete mode 100644 tests/TestCase/Storage/Factories/ReplicateFactoryTest.php delete mode 100644 tests/TestCase/Storage/Factories/SftpFactoryTest.php diff --git a/src/Factories/AwsS3v3Factory.php b/src/Factories/AwsS3v3Factory.php index 6dc10e1..85d8c13 100644 --- a/src/Factories/AwsS3v3Factory.php +++ b/src/Factories/AwsS3v3Factory.php @@ -29,7 +29,7 @@ class AwsS3v3Factory extends AbstractFactory protected string $className = AwsS3V3Adapter::class; protected array $defaults = [ - 'bucket' => null, + 'bucket' => '', 'prefix' => '', 'client' => [ 'region' => 'eu', diff --git a/src/Factories/WebDAVFactory.php b/src/Factories/WebDavFactory.php similarity index 94% rename from src/Factories/WebDAVFactory.php rename to src/Factories/WebDavFactory.php index 45c5112..ebaf297 100644 --- a/src/Factories/WebDAVFactory.php +++ b/src/Factories/WebDavFactory.php @@ -19,9 +19,9 @@ use Sabre\DAV\Client; /** - * WebdavFactory + * WebDavFactory */ -class WebDAVFactory extends AbstractFactory +class WebDavFactory extends AbstractFactory { protected string $alias = 'webdav'; diff --git a/src/Factories/ZipArchiveFactory.php b/src/Factories/ZipArchiveFactory.php index 9350537..fc88a2d 100644 --- a/src/Factories/ZipArchiveFactory.php +++ b/src/Factories/ZipArchiveFactory.php @@ -15,7 +15,9 @@ namespace PhpCollective\Infrastructure\Storage\Factories; use League\Flysystem\FilesystemAdapter; +use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider; use League\Flysystem\ZipArchive\ZipArchiveAdapter; +use League\Flysystem\ZipArchive\ZipArchiveProvider; /** * ZipArchiveFactory @@ -35,11 +37,14 @@ public function build(array $config): FilesystemAdapter { $defaults = [ 'location' => null, - 'archive' => null, - 'prefix' => null, + 'root' => '', + 'mimeTypeDetector' => null, + 'visibility' => null, ]; $config += $defaults; - return new ZipArchiveAdapter($config['location'], $config['archive'], $config['prefix']); + $provider = new FileSystemZipArchiveProvider($config['location']); + + return new ZipArchiveAdapter($provider, $config['root'], $config['mimeTypeDetector'], $config['visibility']); } } diff --git a/tests/TestCase/Storage/Factories/AwsS3v3FactoryTest.php b/tests/TestCase/Storage/Factories/AwsS3v3FactoryTest.php index 3573a2c..b6a4cd3 100644 --- a/tests/TestCase/Storage/Factories/AwsS3v3FactoryTest.php +++ b/tests/TestCase/Storage/Factories/AwsS3v3FactoryTest.php @@ -14,7 +14,7 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; -use League\Flysystem\AwsS3v3\AwsS3Adapter; +use League\Flysystem\AwsS3V3\AwsS3V3Adapter; use PhpCollective\Infrastructure\Storage\Factories\AwsS3v3Factory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; @@ -30,6 +30,6 @@ public function testFactory(): void { $factory = new AwsS3v3Factory(); $adapter = $factory->build([]); - $this->assertInstanceOf(AwsS3Adapter::class, $adapter); + $this->assertInstanceOf(AwsS3V3Adapter::class, $adapter); } } diff --git a/tests/TestCase/Storage/Factories/FtpFactoryTest.php b/tests/TestCase/Storage/Factories/FtpFactoryTest.php deleted file mode 100644 index 1631136..0000000 --- a/tests/TestCase/Storage/Factories/FtpFactoryTest.php +++ /dev/null @@ -1,35 +0,0 @@ -build([]); - $this->assertInstanceOf(Ftp::class, $adapter); - } -} diff --git a/tests/TestCase/Storage/Factories/LocalFactoryTest.php b/tests/TestCase/Storage/Factories/LocalFactoryTest.php index 039539b..4968f10 100644 --- a/tests/TestCase/Storage/Factories/LocalFactoryTest.php +++ b/tests/TestCase/Storage/Factories/LocalFactoryTest.php @@ -15,6 +15,7 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; use League\Flysystem\Adapter\Local; +use League\Flysystem\Local\LocalFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Factories\LocalFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; @@ -32,6 +33,6 @@ public function testFactory(): void $adapter = $factory->build([ 'root' => sys_get_temp_dir(), ]); - $this->assertInstanceOf(Local::class, $adapter); + $this->assertInstanceOf(LocalFilesystemAdapter::class, $adapter); } } diff --git a/tests/TestCase/Storage/Factories/MemoryFactoryTest.php b/tests/TestCase/Storage/Factories/MemoryFactoryTest.php index a5dd81d..e0f1c38 100644 --- a/tests/TestCase/Storage/Factories/MemoryFactoryTest.php +++ b/tests/TestCase/Storage/Factories/MemoryFactoryTest.php @@ -14,7 +14,7 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; -use League\Flysystem\Memory\MemoryAdapter; +use League\Flysystem\InMemory\InMemoryFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Factories\MemoryFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; @@ -30,6 +30,6 @@ public function testFactory(): void { $factory = new MemoryFactory(); $result = $factory->build([]); - $this->assertInstanceOf(MemoryAdapter::class, $result); + $this->assertInstanceOf(InMemoryFilesystemAdapter::class, $result); } } diff --git a/tests/TestCase/Storage/Factories/NullFactoryTest.php b/tests/TestCase/Storage/Factories/NullFactoryTest.php index 83e23e9..27ede81 100644 --- a/tests/TestCase/Storage/Factories/NullFactoryTest.php +++ b/tests/TestCase/Storage/Factories/NullFactoryTest.php @@ -15,6 +15,7 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; use League\Flysystem\Adapter\NullAdapter; +use PhpCollective\Infrastructure\Storage\Adapter\NullFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Factories\NullFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; @@ -30,6 +31,6 @@ public function testFactory(): void { $factory = new NullFactory(); $adapter = $factory->build([]); - $this->assertInstanceOf(NullAdapter::class, $adapter); + $this->assertInstanceOf(NullFilesystemAdapter::class, $adapter); } } diff --git a/tests/TestCase/Storage/Factories/RackspaceFactoryTest.php b/tests/TestCase/Storage/Factories/RackspaceFactoryTest.php deleted file mode 100644 index d2a3811..0000000 --- a/tests/TestCase/Storage/Factories/RackspaceFactoryTest.php +++ /dev/null @@ -1,53 +0,0 @@ -getMockBuilder(RackspaceFactory::class) - ->setMethods([ - 'buildClient' - ]) - ->getMock(); - - $client = $this->getMockBuilder(Rackspace::class) - ->disableOriginalConstructor() - ->getMock(); - - $factory->expects($this->any()) - ->method('buildClient') - ->willReturn($client); - - $adapter = $factory->build([ - 'serviceRegion' => 'uk', - 'username' => '', - 'apiKey' => '' - ]); - - $this->assertInstanceOf(RackspaceAdapter::class, $adapter); - */ - } -} diff --git a/tests/TestCase/Storage/Factories/ReplicateFactoryTest.php b/tests/TestCase/Storage/Factories/ReplicateFactoryTest.php deleted file mode 100644 index 335695f..0000000 --- a/tests/TestCase/Storage/Factories/ReplicateFactoryTest.php +++ /dev/null @@ -1,66 +0,0 @@ -build([ - 'source' => new NullAdapter(), - 'target' => new NullAdapter(), - ]); - $this->assertInstanceOf(ReplicateAdapter::class, $adapter); - } - - /** - * @return void - */ - public function testMissingConfig(): void - { - $factory = new ReplicateFactory(); - - $this->expectException(FactoryException::class); - $factory->build([ - 'target' => new NullAdapter(), - ]); - } - - /** - * @return void - */ - public function testMissingConfig2(): void - { - $factory = new ReplicateFactory(); - - $this->expectException(FactoryException::class); - $factory->build([ - 'target' => new NullAdapter(), - ]); - } -} diff --git a/tests/TestCase/Storage/Factories/SftpFactoryTest.php b/tests/TestCase/Storage/Factories/SftpFactoryTest.php deleted file mode 100644 index 155012c..0000000 --- a/tests/TestCase/Storage/Factories/SftpFactoryTest.php +++ /dev/null @@ -1,35 +0,0 @@ -build([]); - $this->assertInstanceOf(SftpAdapter::class, $adapter); - } -} diff --git a/tests/TestCase/Storage/Factories/WebDavFactoryTest.php b/tests/TestCase/Storage/Factories/WebDavFactoryTest.php index b843ad1..c5ea93c 100644 --- a/tests/TestCase/Storage/Factories/WebDavFactoryTest.php +++ b/tests/TestCase/Storage/Factories/WebDavFactoryTest.php @@ -15,7 +15,7 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; use League\Flysystem\WebDAV\WebDAVAdapter; -use PhpCollective\Infrastructure\Storage\Factories\WebDAVFactory; +use PhpCollective\Infrastructure\Storage\Factories\WebDavFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; /** @@ -28,7 +28,7 @@ class WebDavFactoryTest extends TestCase */ public function testFactory(): void { - $factory = new WebDAVFactory(); + $factory = new WebDavFactory(); $adapter = $factory->build([ 'baseUri' => '/', ]); diff --git a/tests/TestCase/Storage/StorageAdapterFactoryTest.php b/tests/TestCase/Storage/StorageAdapterFactoryTest.php index 15023ee..326a238 100644 --- a/tests/TestCase/Storage/StorageAdapterFactoryTest.php +++ b/tests/TestCase/Storage/StorageAdapterFactoryTest.php @@ -15,6 +15,7 @@ namespace PhpCollective\Storage\Test\TestCase\Storage; use League\Flysystem\Adapter\Local; +use League\Flysystem\Local\LocalFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Exception\AdapterFactoryNotFoundException; use PhpCollective\Infrastructure\Storage\StorageAdapterFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; @@ -37,7 +38,7 @@ public function testBuildStorageAdapter(): void 'root' => $this->testPath, ]); - $this->assertInstanceOf(Local::class, $result); + $this->assertInstanceOf(LocalFilesystemAdapter::class, $result); } /** From 94cfd08e1207867774308652598580a643914f76 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 27 Dec 2023 18:44:20 +0100 Subject: [PATCH 3/3] Fix CS --- src/Factories/ZipArchiveFactory.php | 1 - tests/TestCase/Storage/Factories/LocalFactoryTest.php | 1 - tests/TestCase/Storage/Factories/NullFactoryTest.php | 1 - tests/TestCase/Storage/StorageAdapterFactoryTest.php | 1 - 4 files changed, 4 deletions(-) diff --git a/src/Factories/ZipArchiveFactory.php b/src/Factories/ZipArchiveFactory.php index fc88a2d..b300a38 100644 --- a/src/Factories/ZipArchiveFactory.php +++ b/src/Factories/ZipArchiveFactory.php @@ -17,7 +17,6 @@ use League\Flysystem\FilesystemAdapter; use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider; use League\Flysystem\ZipArchive\ZipArchiveAdapter; -use League\Flysystem\ZipArchive\ZipArchiveProvider; /** * ZipArchiveFactory diff --git a/tests/TestCase/Storage/Factories/LocalFactoryTest.php b/tests/TestCase/Storage/Factories/LocalFactoryTest.php index 4968f10..c3de095 100644 --- a/tests/TestCase/Storage/Factories/LocalFactoryTest.php +++ b/tests/TestCase/Storage/Factories/LocalFactoryTest.php @@ -14,7 +14,6 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; -use League\Flysystem\Adapter\Local; use League\Flysystem\Local\LocalFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Factories\LocalFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; diff --git a/tests/TestCase/Storage/Factories/NullFactoryTest.php b/tests/TestCase/Storage/Factories/NullFactoryTest.php index 27ede81..41f678c 100644 --- a/tests/TestCase/Storage/Factories/NullFactoryTest.php +++ b/tests/TestCase/Storage/Factories/NullFactoryTest.php @@ -14,7 +14,6 @@ namespace PhpCollective\Storage\Test\TestCase\Storage\Factories; -use League\Flysystem\Adapter\NullAdapter; use PhpCollective\Infrastructure\Storage\Adapter\NullFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Factories\NullFactory; use PhpCollective\Storage\Test\TestCase\StorageTestCase as TestCase; diff --git a/tests/TestCase/Storage/StorageAdapterFactoryTest.php b/tests/TestCase/Storage/StorageAdapterFactoryTest.php index 326a238..0e1cb17 100644 --- a/tests/TestCase/Storage/StorageAdapterFactoryTest.php +++ b/tests/TestCase/Storage/StorageAdapterFactoryTest.php @@ -14,7 +14,6 @@ namespace PhpCollective\Storage\Test\TestCase\Storage; -use League\Flysystem\Adapter\Local; use League\Flysystem\Local\LocalFilesystemAdapter; use PhpCollective\Infrastructure\Storage\Exception\AdapterFactoryNotFoundException; use PhpCollective\Infrastructure\Storage\StorageAdapterFactory;