@@ -49,6 +49,9 @@ public function setUp()
4949 // Create test key.
5050 $ hmacKeyCreated = $ this ->storage ->createHmacKey ($ this ->hmacServiceAccount , ['projectId ' => self ::$ projectId ]);
5151 $ this ->accessId = $ hmacKeyCreated ->hmacKey ()->accessId ();
52+ $ this ->setOutputCallback (function () {
53+ // disable output
54+ });
5255 }
5356
5457 public function tearDown ()
@@ -61,7 +64,9 @@ private function deleteAllHmacKeys($serviceAccountEmail)
6164 {
6265 $ hmacKeys = $ this ->storage ->hmacKeys (['serviceAccountEmail ' => $ serviceAccountEmail ]);
6366 foreach ($ hmacKeys as $ hmacKey ) {
64- $ hmacKey ->update ('INACTIVE ' );
67+ if ($ hmacKey ->info ()['state ' ] == 'ACTIVE ' ) {
68+ $ hmacKey ->update ('INACTIVE ' );
69+ }
6570 $ hmacKey ->delete ();
6671 }
6772 }
@@ -73,8 +78,7 @@ public function testHmacKeyList()
7378 'projectId ' => self ::$ projectId
7479 ],
7580 ['interactive ' => false ]);
76- $ outputString = "/HMAC key Metadata:/ " ;
77- $ this ->expectOutputRegex ($ outputString );
81+ $ this ->assertContains ("HMAC key Metadata: " , $ this ->getActualOutput ());
7882 }
7983
8084 /** @depends testHmacKeyList */
@@ -86,8 +90,7 @@ public function testHmacKeyCreate()
8690 'serviceAccountEmail ' => $ this ->hmacServiceAccount
8791 ],
8892 ['interactive ' => false ]);
89- $ outputString = "/The base64 encoded secret is:/ " ;
90- $ this ->expectOutputRegex ($ outputString );
93+ $ this ->assertContains ("The base64 encoded secret is: " , $ this ->getActualOutput ());
9194 }
9295
9396 /** @depends testHmacKeyCreate */
@@ -100,12 +103,11 @@ public function testHmacKeyGet()
100103 '--get ' => true
101104 ],
102105 ['interactive ' => false ]);
103- $ outputString = "/HMAC key Metadata:/ " ;
104- $ this ->expectOutputRegex ($ outputString );
106+ $ this ->assertContains ("HMAC key Metadata: " , $ this ->getActualOutput ());
105107 }
106108
107109 /** @depends testHmacKeyGet */
108- public function testHmacKeyDeactivate ()
110+ public function testHmacKeyDeactivateActivate ()
109111 {
110112 $ this ->commandTesterManage ->execute (
111113 [
@@ -114,25 +116,17 @@ public function testHmacKeyDeactivate()
114116 '--deactivate ' => true
115117 ],
116118 ['interactive ' => false ]);
117- $ outputString = "/The HMAC key is now inactive./ " ;
118- $ this ->expectOutputRegex ($ outputString );
119- }
120-
121- /** @depends testHmacKeyDeactivate */
122- public function testHmacKeyActivate ()
123- {
119+ $ this ->assertContains ("The HMAC key is now inactive " , $ this ->getActualOutput ());
124120 $ this ->commandTesterManage ->execute (
125- [
126- 'projectId ' => self ::$ projectId ,
127- 'accessId ' => $ this ->accessId ,
128- '--activate ' => true
129- ],
130- ['interactive ' => false ]);
131- $ outputString = "/The HMAC key is now active./ " ;
132- $ this ->expectOutputRegex ($ outputString );
121+ [
122+ 'projectId ' => self ::$ projectId ,
123+ 'accessId ' => $ this ->accessId ,
124+ '--activate ' => true
125+ ],
126+ ['interactive ' => false ]);
127+ $ this ->assertContains ("The HMAC key is now active " , $ this ->getActualOutput ());
133128 }
134-
135- /** @depends testHmacKeyActivate */
129+ /** @depends testHmacKeyDeactivateActivate */
136130 public function testHmacKeyDelete ()
137131 {
138132 $ this ->commandTesterManage ->execute (
@@ -149,7 +143,6 @@ public function testHmacKeyDelete()
149143 '--delete ' => true
150144 ],
151145 ['interactive ' => false ]);
152- $ outputString = "/The key is deleted, though it may still appear in StorageClient.hmacKeys() results./ " ;
153- $ this ->expectOutputRegex ($ outputString );
146+ $ this ->assertContains ("The key is deleted, " , $ this ->getActualOutput ());
154147 }
155148}
0 commit comments