From 356091e28a50b4470b9323de495631fcc2355167 Mon Sep 17 00:00:00 2001 From: mattfoster7 <38736065+mattfoster7@users.noreply.github.com> Date: Mon, 10 Aug 2020 16:07:52 -0400 Subject: [PATCH 01/11] Update GoogleStorageAdapter.php --- src/GoogleStorageAdapter.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/GoogleStorageAdapter.php b/src/GoogleStorageAdapter.php index d5e6c9d..be25251 100755 --- a/src/GoogleStorageAdapter.php +++ b/src/GoogleStorageAdapter.php @@ -139,13 +139,14 @@ public function updateStream($path, $resource, Config $config) protected function getOptionsFromConfig(Config $config) { $options = []; - - if ($visibility = $config->get('visibility')) { - $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); - } else { - // if a file is created without an acl, it isn't accessible via the console - // we therefore default to private - $options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE); + if (!($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'] ?? false)) { + if ($visibility = $config->get('visibility')) { + $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); + } else { + // if a file is created without an acl, it isn't accessible via the console + // we therefore default to private + $options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE); + } } if ($metadata = $config->get('metadata')) { From c4daa6e4ed73dd2a9be1e213aff7ce9837ae16b5 Mon Sep 17 00:00:00 2001 From: mattfoster7 <38736065+mattfoster7@users.noreply.github.com> Date: Mon, 10 Aug 2020 16:24:23 -0400 Subject: [PATCH 02/11] Update GoogleStorageAdapter.php --- src/GoogleStorageAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GoogleStorageAdapter.php b/src/GoogleStorageAdapter.php index be25251..3547299 100755 --- a/src/GoogleStorageAdapter.php +++ b/src/GoogleStorageAdapter.php @@ -139,7 +139,7 @@ public function updateStream($path, $resource, Config $config) protected function getOptionsFromConfig(Config $config) { $options = []; - if (!($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'] ?? false)) { + if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled']) { if ($visibility = $config->get('visibility')) { $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); } else { From 40a142a55149cfb198e6560c7c08695523c5ef03 Mon Sep 17 00:00:00 2001 From: mattfoster7 <38736065+mattfoster7@users.noreply.github.com> Date: Mon, 10 Aug 2020 16:38:33 -0400 Subject: [PATCH 03/11] Update GoogleStorageAdapter.php --- src/GoogleStorageAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GoogleStorageAdapter.php b/src/GoogleStorageAdapter.php index 3547299..f193752 100755 --- a/src/GoogleStorageAdapter.php +++ b/src/GoogleStorageAdapter.php @@ -139,7 +139,7 @@ public function updateStream($path, $resource, Config $config) protected function getOptionsFromConfig(Config $config) { $options = []; - if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled']) { + if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'])) { if ($visibility = $config->get('visibility')) { $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); } else { From 08226a5f26571f0b3430b6cec1d3fb61d079e9d3 Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 15:19:33 +0200 Subject: [PATCH 04/11] Apply correct acl for uniform acl buckets --- src/GoogleStorageAdapter.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/GoogleStorageAdapter.php b/src/GoogleStorageAdapter.php index d5e6c9d..a3e6b51 100755 --- a/src/GoogleStorageAdapter.php +++ b/src/GoogleStorageAdapter.php @@ -140,12 +140,14 @@ protected function getOptionsFromConfig(Config $config) { $options = []; - if ($visibility = $config->get('visibility')) { - $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); - } else { - // if a file is created without an acl, it isn't accessible via the console - // we therefore default to private - $options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE); + if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'])) { + if ($visibility = $config->get('visibility')) { + $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); + } else { + // if a file is created without an acl, it isn't accessible via the console + // we therefore default to private + $options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE); + } } if ($metadata = $config->get('metadata')) { From 3586b10d229608066c2019e3ff42905de6bb9c09 Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 15:28:13 +0200 Subject: [PATCH 05/11] . --- src/GoogleStorageAdapter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GoogleStorageAdapter.php b/src/GoogleStorageAdapter.php index a3e6b51..0463586 100755 --- a/src/GoogleStorageAdapter.php +++ b/src/GoogleStorageAdapter.php @@ -140,6 +140,7 @@ protected function getOptionsFromConfig(Config $config) { $options = []; + if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'])) { if ($visibility = $config->get('visibility')) { $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); From 86bc43cc23e0313e1a31221a4ac9d55229793c8a Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 15:37:32 +0200 Subject: [PATCH 06/11] Updated unit tests --- tests/GoogleStorageAdapterTests.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/GoogleStorageAdapterTests.php b/tests/GoogleStorageAdapterTests.php index 450dc51..b2017d6 100755 --- a/tests/GoogleStorageAdapterTests.php +++ b/tests/GoogleStorageAdapterTests.php @@ -43,6 +43,7 @@ public function testWrite() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -87,6 +88,7 @@ public function testWriteWithPrivateVisibility() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -131,6 +133,7 @@ public function testWriteWithPublicVisibility() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -177,6 +180,7 @@ public function testWriteStream() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -360,6 +364,7 @@ public function testDeleteDir() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -406,6 +411,7 @@ public function testDeleteDirWithTrailingSlash() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -456,6 +462,7 @@ public function testSetVisibilityPrivate() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -497,6 +504,7 @@ public function testSetVisibilityPublic() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -550,6 +558,7 @@ public function testRead() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -591,6 +600,7 @@ public function testReadStream() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -678,6 +688,7 @@ protected function getMockDirObjects($prefix = '') $dir1->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'application/octet-stream', 'size' => 0, @@ -690,6 +701,7 @@ protected function getMockDirObjects($prefix = '') $dir1file1->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -702,6 +714,7 @@ protected function getMockDirObjects($prefix = '') $dir2file1->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -726,6 +739,7 @@ public function testGetMetadataForFile() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -764,6 +778,7 @@ public function testGetMetadataForDir() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'application/octet-stream', 'size' => 0, @@ -802,6 +817,7 @@ public function testGetSize() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -832,6 +848,7 @@ public function testGetMimetype() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -862,6 +879,7 @@ public function testGetTimestamp() $storageObject->shouldReceive('info') ->once() ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, From 0105d89aa7d01597c7a03ae9e8de2fd4c3015871 Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 15:54:55 +0200 Subject: [PATCH 07/11] testing tests --- src/GoogleStorageAdapter.php | 1 - tests/GoogleStorageAdapterTests.php | 58 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/GoogleStorageAdapter.php b/src/GoogleStorageAdapter.php index 0463586..a3e6b51 100755 --- a/src/GoogleStorageAdapter.php +++ b/src/GoogleStorageAdapter.php @@ -140,7 +140,6 @@ protected function getOptionsFromConfig(Config $config) { $options = []; - if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'])) { if ($visibility = $config->get('visibility')) { $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility); diff --git a/tests/GoogleStorageAdapterTests.php b/tests/GoogleStorageAdapterTests.php index b2017d6..404f0e3 100755 --- a/tests/GoogleStorageAdapterTests.php +++ b/tests/GoogleStorageAdapterTests.php @@ -40,7 +40,8 @@ public function testWrite() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -48,7 +49,6 @@ public function testWrite() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('upload') ->withArgs([ 'This is the file contents.', @@ -85,7 +85,8 @@ public function testWriteWithPrivateVisibility() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -93,7 +94,6 @@ public function testWriteWithPrivateVisibility() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('upload') ->withArgs([ 'This is the file contents.', @@ -130,7 +130,7 @@ public function testWriteWithPublicVisibility() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - $storageObject->shouldReceive('info') + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -177,7 +177,7 @@ public function testWriteStream() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - $storageObject->shouldReceive('info') + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -361,7 +361,8 @@ public function testDeleteDir() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/dir_name/directory1/file1.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -369,7 +370,6 @@ public function testDeleteDir() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/dir_name/directory1/file1.txt') ->once() @@ -408,7 +408,8 @@ public function testDeleteDirWithTrailingSlash() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/dir_name/directory1/file1.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -416,7 +417,6 @@ public function testDeleteDirWithTrailingSlash() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/dir_name/directory1/file1.txt') ->once() @@ -459,7 +459,8 @@ public function testSetVisibilityPrivate() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -467,7 +468,6 @@ public function testSetVisibilityPrivate() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file1.txt') ->once() @@ -501,7 +501,8 @@ public function testSetVisibilityPublic() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -509,7 +510,6 @@ public function testSetVisibilityPublic() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file1.txt') ->once() @@ -555,7 +555,8 @@ public function testRead() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -563,7 +564,6 @@ public function testRead() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -597,7 +597,8 @@ public function testReadStream() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -605,7 +606,6 @@ public function testReadStream() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -688,7 +688,6 @@ protected function getMockDirObjects($prefix = '') $dir1->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'application/octet-stream', 'size' => 0, @@ -701,7 +700,6 @@ protected function getMockDirObjects($prefix = '') $dir1file1->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -714,7 +712,6 @@ protected function getMockDirObjects($prefix = '') $dir2file1->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, @@ -736,7 +733,8 @@ public function testGetMetadataForFile() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -744,7 +742,6 @@ public function testGetMetadataForFile() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -775,7 +772,8 @@ public function testGetMetadataForDir() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/directory/'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -783,7 +781,6 @@ public function testGetMetadataForDir() 'contentType' => 'application/octet-stream', 'size' => 0, ]); - $bucket->shouldReceive('object') ->with('prefix/directory') ->once() @@ -814,7 +811,8 @@ public function testGetSize() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -845,7 +843,8 @@ public function testGetMimetype() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -853,7 +852,6 @@ public function testGetMimetype() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -876,7 +874,8 @@ public function testGetTimestamp() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - $storageObject->shouldReceive('info') + + $bucket->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -884,7 +883,6 @@ public function testGetTimestamp() 'contentType' => 'text/plain', 'size' => 5, ]); - $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() From 93203611d7b28c4e3b24bcc0591a163ba53df47b Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 16:23:39 +0200 Subject: [PATCH 08/11] Added info method to bucket mock --- tests/GoogleStorageAdapterTests.php | 131 +++++++++++++++++++--------- 1 file changed, 89 insertions(+), 42 deletions(-) diff --git a/tests/GoogleStorageAdapterTests.php b/tests/GoogleStorageAdapterTests.php index 404f0e3..1ab6ef1 100755 --- a/tests/GoogleStorageAdapterTests.php +++ b/tests/GoogleStorageAdapterTests.php @@ -40,8 +40,7 @@ public function testWrite() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], @@ -49,6 +48,11 @@ public function testWrite() 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('upload') ->withArgs([ 'This is the file contents.', @@ -85,15 +89,19 @@ public function testWriteWithPrivateVisibility() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); + $bucket->shouldReceive('upload') ->withArgs([ 'This is the file contents.', @@ -130,15 +138,18 @@ public function testWriteWithPublicVisibility() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('upload') ->withArgs([ 'This is the file contents.', @@ -177,15 +188,18 @@ public function testWriteStream() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file1.txt'); - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('upload') ->withArgs([ $stream, @@ -361,15 +375,18 @@ public function testDeleteDir() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/dir_name/directory1/file1.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/dir_name/directory1/file1.txt') ->once() @@ -408,15 +425,19 @@ public function testDeleteDirWithTrailingSlash() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/dir_name/directory1/file1.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); + $bucket->shouldReceive('object') ->with('prefix/dir_name/directory1/file1.txt') ->once() @@ -459,15 +480,18 @@ public function testSetVisibilityPrivate() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file1.txt') ->once() @@ -501,15 +525,18 @@ public function testSetVisibilityPublic() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file1.txt') ->once() @@ -555,15 +582,18 @@ public function testRead() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -597,15 +627,18 @@ public function testReadStream() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -733,15 +766,18 @@ public function testGetMetadataForFile() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -772,15 +808,18 @@ public function testGetMetadataForDir() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/directory/'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'application/octet-stream', 'size' => 0, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/directory') ->once() @@ -811,16 +850,18 @@ public function testGetSize() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -843,15 +884,18 @@ public function testGetMimetype() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() @@ -874,15 +918,18 @@ public function testGetTimestamp() $storageObject->shouldReceive('name') ->once() ->andReturn('prefix/file.txt'); - - $bucket->shouldReceive('info') + $storageObject->shouldReceive('info') ->once() ->andReturn([ - 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]], 'updated' => '2016-09-26T14:44:42+00:00', 'contentType' => 'text/plain', 'size' => 5, ]); + + $bucket->shouldReceive('info') + ->andReturn([ + 'iamConfiguration' => ['uniformBucketLevelAccess' => ['enabled' => false]] + ]); $bucket->shouldReceive('object') ->with('prefix/file.txt') ->once() From 7b1f97484c3e4ee0771b2bbd1f6dadd1456bf883 Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 16:33:20 +0200 Subject: [PATCH 09/11] Bumped phpunit one major --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3972104..e0e5340 100755 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "google/cloud-storage": "~1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0", + "phpunit/phpunit": "~5.0", "mockery/mockery": "0.9.*" }, "autoload": { From 650e74b57adc85fa743bdece016504ad3fd8d506 Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 16:47:58 +0200 Subject: [PATCH 10/11] phpunit 5 trigger deprecations in php7.3, phpunit 6 requires php >= 7 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c962694..84a0fa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ php: - 5.6 - 7.1 - 7.2 - - 7.3 env: - GOOGLE_CLOUD_STORAGE="1.0.*" From bf84abedaf08e0479ffdefa3b4396e95623fcdab Mon Sep 17 00:00:00 2001 From: Fredrik Sundblom Date: Fri, 23 Apr 2021 17:05:53 +0200 Subject: [PATCH 11/11] Re added the php 7.3 target --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 84a0fa7..c962694 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - 5.6 - 7.1 - 7.2 + - 7.3 env: - GOOGLE_CLOUD_STORAGE="1.0.*"