@@ -49,6 +49,9 @@ public function setUp()
49
49
// Create test key.
50
50
$ hmacKeyCreated = $ this ->storage ->createHmacKey ($ this ->hmacServiceAccount , ['projectId ' => self ::$ projectId ]);
51
51
$ this ->accessId = $ hmacKeyCreated ->hmacKey ()->accessId ();
52
+ $ this ->setOutputCallback (function () {
53
+ // disable output
54
+ });
52
55
}
53
56
54
57
public function tearDown ()
@@ -61,7 +64,9 @@ private function deleteAllHmacKeys($serviceAccountEmail)
61
64
{
62
65
$ hmacKeys = $ this ->storage ->hmacKeys (['serviceAccountEmail ' => $ serviceAccountEmail ]);
63
66
foreach ($ hmacKeys as $ hmacKey ) {
64
- $ hmacKey ->update ('INACTIVE ' );
67
+ if ($ hmacKey ->info ()['state ' ] == 'ACTIVE ' ) {
68
+ $ hmacKey ->update ('INACTIVE ' );
69
+ }
65
70
$ hmacKey ->delete ();
66
71
}
67
72
}
@@ -73,8 +78,7 @@ public function testHmacKeyList()
73
78
'projectId ' => self ::$ projectId
74
79
],
75
80
['interactive ' => false ]);
76
- $ outputString = "/HMAC key Metadata:/ " ;
77
- $ this ->expectOutputRegex ($ outputString );
81
+ $ this ->assertContains ("HMAC key Metadata: " , $ this ->getActualOutput ());
78
82
}
79
83
80
84
/** @depends testHmacKeyList */
@@ -86,8 +90,7 @@ public function testHmacKeyCreate()
86
90
'serviceAccountEmail ' => $ this ->hmacServiceAccount
87
91
],
88
92
['interactive ' => false ]);
89
- $ outputString = "/The base64 encoded secret is:/ " ;
90
- $ this ->expectOutputRegex ($ outputString );
93
+ $ this ->assertContains ("The base64 encoded secret is: " , $ this ->getActualOutput ());
91
94
}
92
95
93
96
/** @depends testHmacKeyCreate */
@@ -100,12 +103,11 @@ public function testHmacKeyGet()
100
103
'--get ' => true
101
104
],
102
105
['interactive ' => false ]);
103
- $ outputString = "/HMAC key Metadata:/ " ;
104
- $ this ->expectOutputRegex ($ outputString );
106
+ $ this ->assertContains ("HMAC key Metadata: " , $ this ->getActualOutput ());
105
107
}
106
108
107
109
/** @depends testHmacKeyGet */
108
- public function testHmacKeyDeactivate ()
110
+ public function testHmacKeyDeactivateActivate ()
109
111
{
110
112
$ this ->commandTesterManage ->execute (
111
113
[
@@ -114,25 +116,17 @@ public function testHmacKeyDeactivate()
114
116
'--deactivate ' => true
115
117
],
116
118
['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 ());
124
120
$ 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 ());
133
128
}
134
-
135
- /** @depends testHmacKeyActivate */
129
+ /** @depends testHmacKeyDeactivateActivate */
136
130
public function testHmacKeyDelete ()
137
131
{
138
132
$ this ->commandTesterManage ->execute (
@@ -149,7 +143,6 @@ public function testHmacKeyDelete()
149
143
'--delete ' => true
150
144
],
151
145
['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 ());
154
147
}
155
148
}
0 commit comments