2222use Sabre \DAV \Client as WebDAVClient ;
2323use Spatie \Dropbox \Client as DropboxClient ;
2424use Symfony \Component \Dotenv \Dotenv ;
25+ use Symfony \Component \HttpKernel \Kernel ;
2526use Tests \League \FlysystemBundle \Kernel \FlysystemAppKernel ;
2627
2728class FlysystemExtensionTest extends TestCase
2829{
2930 public function provideFilesystems ()
3031 {
3132 $ fsNames = [
32- 'fs_asyncaws ' ,
3333 'fs_aws ' ,
3434 'fs_azure ' ,
3535 'fs_cache ' ,
@@ -57,7 +57,9 @@ public function provideFilesystems()
5757 public function testFileystems (string $ fsName )
5858 {
5959 $ kernel = $ this ->createFysystemKernel ();
60- $ fs = $ kernel ->getContainer ()->get ('flysystem.test. ' .$ fsName );
60+ $ container = $ kernel ->getContainer ()->get ('test.service_container ' );
61+
62+ $ fs = $ container ->get ('flysystem.test. ' .$ fsName );
6163
6264 $ this ->assertInstanceOf (FilesystemInterface::class, $ fs , 'Filesystem " ' .$ fsName .'" should be an instance of FilesystemInterface ' );
6365 $ this ->assertEquals ('plugin ' , $ fs ->pluginTest ());
@@ -69,12 +71,13 @@ public function testFileystems(string $fsName)
6971 public function testTaggedCollection (string $ fsName )
7072 {
7173 $ kernel = $ this ->createFysystemKernel ();
74+ $ container = $ kernel ->getContainer ()->get ('test.service_container ' );
7275
73- if (!$ kernel -> getContainer () ->has ('storages_tagged_collection ' )) {
76+ if (!$ container ->has ('storages_tagged_collection ' )) {
7477 $ this ->markTestSkipped ('Symfony 4.3+ is required to use indexed tagged service collections ' );
7578 }
7679
77- $ storages = iterator_to_array ($ kernel -> getContainer () ->get ('storages_tagged_collection ' )->locator );
80+ $ storages = iterator_to_array ($ container ->get ('storages_tagged_collection ' )->locator );
7881
7982 $ this ->assertInstanceOf (FilesystemInterface::class, $ storages [$ fsName ]);
8083 $ this ->assertEquals ('plugin ' , $ storages [$ fsName ]->pluginTest ());
@@ -92,9 +95,11 @@ private function createFysystemKernel()
9295 $ kernel ->setAdapterClients ($ this ->getClientMocks ());
9396 $ kernel ->boot ();
9497
95- $ container = $ kernel ->getContainer ();
98+ $ container = $ kernel ->getContainer ()-> get ( ' test.service_container ' ) ;
9699 foreach ($ this ->getClientMocks () as $ service => $ mock ) {
97- $ container ->set ($ service , $ mock );
100+ if ($ mock ) {
101+ $ container ->set ($ service , $ mock );
102+ }
98103 }
99104
100105 return $ kernel ;
@@ -105,9 +110,14 @@ private function getClientMocks()
105110 $ gcloud = $ this ->createMock (StorageClient::class);
106111 $ gcloud ->method ('bucket ' )->willReturn ($ this ->createMock (Bucket::class));
107112
113+ $ asyncAws = null ;
114+ if (Kernel::VERSION_ID > 50200 && class_exists (AsyncS3Client::class)) {
115+ $ asyncAws = $ this ->createMock (AsyncS3Client::class);
116+ }
117+
108118 return [
109119 'aws_client_service ' => $ this ->createMock (S3Client::class),
110- 'asyncaws_client_service ' => $ this -> createMock (AsyncS3Client::class) ,
120+ 'asyncaws_client_service ' => $ asyncAws ,
111121 'azure_client_service ' => $ this ->createMock (BlobRestProxy::class),
112122 'dropbox_client_service ' => $ this ->createMock (DropboxClient::class),
113123 'gcloud_client_service ' => $ gcloud ,
0 commit comments