@@ -137,25 +137,21 @@ public function testSoftDeletePolicy()
137137 {
138138 $ durationSecond = 8 *24 *60 *60 ;
139139 // set soft delete policy
140- self ::$ bucket ->update (
141- [
140+ self ::$ bucket ->update ([
142141 'softDeletePolicy ' => [
143142 'retentionDurationSeconds ' => $ durationSecond
144143 ]
145- ]
146- );
144+ ]);
147145 $ this ->assertArrayHasKey ('softDeletePolicy ' , self ::$ bucket ->info ());
148146 $ this ->assertEquals (
149147 $ durationSecond ,
150148 self ::$ bucket ->info ()['softDeletePolicy ' ]['retentionDurationSeconds ' ]
151149 );
152150
153151 // remove soft delete policy
154- self ::$ bucket ->update (
155- [
152+ self ::$ bucket ->update ([
156153 'softDeletePolicy ' => []
157- ]
158- );
154+ ]);
159155 $ this ->assertArrayHasKey ('softDeletePolicy ' , self ::$ bucket ->info ());
160156 $ this ->assertEquals (
161157 0 ,
@@ -164,7 +160,7 @@ public function testSoftDeletePolicy()
164160 }
165161
166162 /**
167- * @group storage-bucket-lifecycle
163+ * @group storage-bucket-lifecycle
168164 * @dataProvider lifecycleRules
169165 */
170166 public function testCreateBucketWithLifecycleDeleteRule (array $ rule , $ isError = false )
@@ -176,19 +172,15 @@ public function testCreateBucketWithLifecycleDeleteRule(array $rule, $isError =
176172 $ lifecycle = Bucket::lifecycle ();
177173 $ lifecycle ->addDeleteRule ($ rule );
178174
179- $ bucket = self ::createBucket (
180- self ::$ client ,
181- uniqid (self ::TESTING_PREFIX ),
182- [
175+ $ bucket = self ::createBucket (self ::$ client , uniqid (self ::TESTING_PREFIX ), [
183176 'lifecycle ' => $ lifecycle
184- ]
185- );
177+ ]);
186178
187179 $ this ->assertEquals ($ lifecycle ->toArray (), $ bucket ->info ()['lifecycle ' ]);
188180 }
189181
190182 /**
191- * @group storage-bucket-lifecycle
183+ * @group storage-bucket-lifecycle
192184 * @dataProvider lifecycleRules
193185 */
194186 public function testCreateBucketWithLifecycleAbortIncompleteMultipartUploadRule (array $ rule , $ isError = false )
@@ -205,19 +197,15 @@ public function testCreateBucketWithLifecycleAbortIncompleteMultipartUploadRule(
205197 $ lifecycle = Bucket::lifecycle ();
206198 $ lifecycle ->addAbortIncompleteMultipartUploadRule ($ rule );
207199
208- $ bucket = self ::createBucket (
209- self ::$ client ,
210- uniqid (self ::TESTING_PREFIX ),
211- [
200+ $ bucket = self ::createBucket (self ::$ client , uniqid (self ::TESTING_PREFIX ), [
212201 'lifecycle ' => $ lifecycle
213- ]
214- );
202+ ]);
215203
216204 $ this ->assertEquals ($ lifecycle ->toArray (), $ bucket ->info ()['lifecycle ' ]);
217205 }
218206
219207 /**
220- * @group storage-bucket-lifecycle
208+ * @group storage-bucket-lifecycle
221209 * @dataProvider lifecycleRules
222210 */
223211 public function testUpdateBucketWithLifecycleDeleteRule (array $ rule , $ isError = false )
@@ -232,11 +220,9 @@ public function testUpdateBucketWithLifecycleDeleteRule(array $rule, $isError =
232220 $ bucket = self ::createBucket (self ::$ client , uniqid (self ::TESTING_PREFIX ));
233221 $ this ->assertArrayNotHasKey ('lifecycle ' , $ bucket ->info ());
234222
235- $ bucket ->update (
236- [
223+ $ bucket ->update ([
237224 'lifecycle ' => $ lifecycle
238- ]
239- );
225+ ]);
240226
241227 $ this ->assertEquals ($ lifecycle ->toArray (), $ bucket ->info ()['lifecycle ' ]);
242228 }
@@ -330,11 +316,9 @@ public function lifecycleRules()
330316 public function testUpdateAndClearLifecycle ()
331317 {
332318 $ lifecycle = self ::$ bucket ->currentLifecycle ()
333- ->addDeleteRule (
334- [
319+ ->addDeleteRule ([
335320 'age ' => 500
336- ]
337- );
321+ ]);
338322 $ info = self ::$ bucket ->update (['lifecycle ' => $ lifecycle ]);
339323
340324 $ this ->assertEquals ($ lifecycle ->toArray (), $ info ['lifecycle ' ]);
@@ -377,12 +361,9 @@ public function testIam()
377361
378362 $ policy = $ iam ->reload ();
379363
380- $ newBinding = array_filter (
381- $ policy ['bindings ' ],
382- function ($ binding ) use ($ role ) {
383- return ($ binding ['role ' ] === $ role );
384- }
385- );
364+ $ newBinding = array_filter ($ policy ['bindings ' ], function ($ binding ) use ($ role ) {
365+ return ($ binding ['role ' ] === $ role );
366+ });
386367
387368 $ this ->assertCount (1 , $ newBinding );
388369
@@ -395,61 +376,51 @@ public function testLabels()
395376 {
396377 $ bucket = self ::$ bucket ;
397378
398- $ bucket ->update (
399- [
379+ $ bucket ->update ([
400380 'labels ' => [
401381 'foo ' => 'bar '
402382 ]
403- ]
404- );
383+ ]);
405384
406385 $ bucket ->reload ();
407386
408387 $ this ->assertEquals ($ bucket ->info ()['labels ' ]['foo ' ], 'bar ' );
409388
410- $ bucket ->update (
411- [
389+ $ bucket ->update ([
412390 'labels ' => [
413391 'foo ' => 'bat '
414392 ]
415- ]
416- );
393+ ]);
417394
418395 $ bucket ->reload ();
419396
420397 $ this ->assertEquals ($ bucket ->info ()['labels ' ]['foo ' ], 'bat ' );
421398
422- $ bucket ->update (
423- [
399+ $ bucket ->update ([
424400 'labels ' => [
425401 'foo ' => null
426402 ]
427- ]
428- );
403+ ]);
429404
430405 $ bucket ->reload ();
431406
432407 $ this ->assertFalse (isset ($ bucket ->info ()['labels ' ]['foo ' ]));
433408 }
434409
435410 /**
436- * @group storage-bucket-location
411+ * @group storage-bucket-location
437412 * @dataProvider locationTypes
438413 */
439414 public function testBucketLocationType ($ storageClass , $ location , $ expectedLocationType , $ updateStorageClass )
440415 {
441416 $ bucketName = uniqid (self ::TESTING_PREFIX );
442- $ bucket = self ::createBucket (
443- self ::$ client ,
444- $ bucketName ,
445- [
417+ $ bucket = self ::createBucket (self ::$ client , $ bucketName , [
446418 'storageClass ' => $ storageClass ,
447419 'location ' => $ location ,
448420 'retentionPolicy ' => [
449421 'retentionPeriod ' => 1
450422 ]
451- ]
452- );
423+ ]);
453424
454425 // Test create bucket response
455426 $ this ->assertEquals ($ expectedLocationType , $ bucket ->info ()['locationType ' ]);
@@ -464,14 +435,9 @@ public function testBucketLocationType($storageClass, $location, $expectedLocati
464435
465436 // Test list bucket response
466437 $ buckets = iterator_to_array (self ::$ client ->buckets ());
467- $ listBucketBucket = current (
468- array_filter (
469- $ buckets ,
470- function ($ bucket ) use ($ bucketName ) {
471- return $ bucket ->name () === $ bucketName ;
472- }
473- )
474- );
438+ $ listBucketBucket = current (array_filter ($ buckets , function ($ bucket ) use ($ bucketName ) {
439+ return $ bucket ->name () === $ bucketName ;
440+ }));
475441 $ this ->assertEquals ($ expectedLocationType , $ listBucketBucket ->info ()['locationType ' ]);
476442
477443 // Test lock retention policy response
@@ -614,11 +580,7 @@ public function encryptionEnforcementConfigs()
614580 }
615581
616582 /**
617- * Creates a bucket with IP filter disabled.
618- *
619- * @group storage-ipfilter
620- *
621- * @return Bucket
583+ * @group bucket-ipfilter
622584 */
623585 public function testCreateBucketWithIpFilterDisabled ()
624586 {
@@ -662,37 +624,33 @@ public function testCreateBucketWithIpFilterDisabled()
662624 }
663625
664626 /**
665- * Deletes an IP from the bucket IP filter.
666- *
667627 * @depends testCreateBucketWithIpFilterDisabled
668- * @group storage-ipfilter
669- *
670- * @param Bucket $bucket The bucket.
671- *
672- * @return void
628+ * @group storage-ipfilter
673629 */
674- public function testDeleteBucketIpFilter (Bucket $ bucket )
630+ public function testUpdateIpFilterDisabled (Bucket $ bucket )
675631 {
676632 $ ipFilterConfig = [
677633 'mode ' => 'Disabled ' ,
678634 'publicNetworkSource ' => [
679- 'allowedIpCidrRanges ' => []
635+ 'allowedIpCidrRanges ' => [' 1.2.3.0/24 ' , ' 5.6.7.0/24 ' ]
680636 ],
681- 'allowAllServiceAgentAccess ' => true
637+ 'allowAllServiceAgentAccess ' => false
682638 ];
683639
684640 $ bucket ->update (['ipFilter ' => $ ipFilterConfig ]);
685641 $ info = $ bucket ->reload ();
686642
687- $ this ->assertArrayNotHasKey ('allowedIpCidrRanges ' , $ info ['ipFilter ' ]['publicNetworkSource ' ]);
643+ $ this ->assertArrayHasKey ('ipFilter ' , $ info );
644+ $ this ->assertEquals ('Disabled ' , $ info ['ipFilter ' ]['mode ' ]);
645+ $ this ->assertEquals (
646+ ['1.2.3.0/24 ' , '5.6.7.0/24 ' ],
647+ $ info ['ipFilter ' ]['publicNetworkSource ' ]['allowedIpCidrRanges ' ]
648+ );
649+ $ this ->assertFalse ($ info ['ipFilter ' ]['allowAllServiceAgentAccess ' ]);
688650 }
689651
690652 /**
691- * Tests creating a bucket with invalid IP filter fails.
692- *
693653 * @group storage-ipfilter
694- *
695- * @return void
696654 */
697655 public function testCreateBucketWithInvalidIpFilterFails ()
698656 {
@@ -718,6 +676,9 @@ public function testCreateBucketWithInvalidIpFilterFails()
718676 );
719677 }
720678
679+ /**
680+ * @group storage-ipfilter
681+ */
721682 public function testUpdateBucketWithInvalidIpFilterFails ()
722683 {
723684 $ bucket = self ::createBucket (self ::$ client , uniqid (self ::TESTING_PREFIX ));
@@ -735,6 +696,9 @@ public function testUpdateBucketWithInvalidIpFilterFails()
735696 $ bucket ->update (['ipFilter ' => $ ipFilterConfig ]);
736697 }
737698
699+ /**
700+ * @group storage-ipfilter
701+ */
738702 public function testGetBucketWithIpFilter ()
739703 {
740704 $ bucketName = uniqid (self ::TESTING_PREFIX );
@@ -763,6 +727,31 @@ public function testGetBucketWithIpFilter()
763727 );
764728 }
765729
730+ /**
731+ * @group storage-ipfilter
732+ * @depends testCreateBucketWithIpFilterDisabled
733+ */
734+ public function testDeleteBucketIpFilter (Bucket $ bucket )
735+ {
736+ $ ipFilterConfig = [
737+ 'mode ' => 'Disabled ' ,
738+ 'publicNetworkSource ' => [
739+ 'allowedIpCidrRanges ' => []
740+ ],
741+ 'allowAllServiceAgentAccess ' => true
742+ ];
743+
744+ $ bucket ->update (['ipFilter ' => $ ipFilterConfig ]);
745+ $ info = $ bucket ->reload ();
746+
747+ $ this ->assertArrayHasKey ('ipFilter ' , $ info );
748+ $ this ->assertEquals ('Disabled ' , $ info ['ipFilter ' ]['mode ' ]);
749+ $ this ->assertArrayNotHasKey ('allowedIpCidrRanges ' , $ info ['ipFilter ' ]['publicNetworkSource ' ]);
750+ }
751+
752+ /**
753+ * @group storage-ipfilter
754+ */
766755 public function testBucketAccessWhenEnforced ()
767756 {
768757 $ iam = self ::$ bucket ->iam ();
0 commit comments