@@ -106,7 +106,17 @@ public function testPfopExecuteWithOptions()
106106 $ testCases = $ this ->pfopOptionsTestData ();
107107
108108 foreach ($ testCases as $ testCase ) {
109- if ($ testCase ['workflowTemplateID ' ]) {
109+ $ workflowTemplateID = null ;
110+ $ type = null ;
111+
112+ if (array_key_exists ('workflowTemplateID ' , $ testCase )) {
113+ $ workflowTemplateID = $ testCase ['workflowTemplateID ' ];
114+ }
115+ if (array_key_exists ('type ' , $ testCase )) {
116+ $ type = $ testCase ['type ' ];
117+ }
118+
119+ if ($ workflowTemplateID ) {
110120 $ fops = null ;
111121 } else {
112122 $ persistentEntry = \Qiniu \entry (
@@ -116,7 +126,7 @@ public function testPfopExecuteWithOptions()
116126 array (
117127 'test-pfop/test-pfop-by-api ' ,
118128 'type ' ,
119- $ testCase [ ' type ' ]
129+ $ type
120130 )
121131 )
122132 );
@@ -129,24 +139,24 @@ public function testPfopExecuteWithOptions()
129139 null ,
130140 null ,
131141 false ,
132- $ testCase [ ' type ' ] ,
133- $ testCase [ ' workflowTemplateID ' ]
142+ $ type ,
143+ $ workflowTemplateID
134144 );
135145
136- if (in_array ($ testCase [ ' type ' ] , array (null , 0 , 1 ))) {
146+ if (in_array ($ type , array (null , 0 , 1 ))) {
137147 $ this ->assertNull ($ error );
138148 list ($ status , $ error ) = $ pfop ->status ($ id );
139149 $ this ->assertNotNull ($ status );
140150 $ this ->assertNull ($ error );
141- if ($ testCase [ ' type ' ] == 1 ) {
151+ if ($ type == 1 ) {
142152 $ this ->assertEquals (1 , $ status ['type ' ]);
143153 }
144- if ($ testCase [ ' workflowTemplateID ' ] ) {
154+ if ($ workflowTemplateID ) {
145155 // assertStringContainsString when PHPUnit >= 8.0
146156 $ this ->assertTrue (
147157 strpos (
148158 $ status ['taskFrom ' ],
149- $ testCase [ ' workflowTemplateID ' ]
159+ $ workflowTemplateID
150160 ) !== false
151161 );
152162 }
@@ -166,11 +176,21 @@ public function testPfopWithUploadPolicy()
166176 $ testCases = $ this ->pfopOptionsTestData ();
167177
168178 foreach ($ testCases as $ testCase ) {
179+ $ workflowTemplateID = null ;
180+ $ type = null ;
181+
182+ if (array_key_exists ('workflowTemplateID ' , $ testCase )) {
183+ $ workflowTemplateID = $ testCase ['workflowTemplateID ' ];
184+ }
185+ if (array_key_exists ('type ' , $ testCase )) {
186+ $ type = $ testCase ['type ' ];
187+ }
188+
169189 $ putPolicy = array (
170- 'persistentType ' => $ testCase [ ' type ' ]
190+ 'persistentType ' => $ type
171191 );
172- if ($ testCase [ ' workflowTemplateID ' ] ) {
173- $ putPolicy ['persistentWorkflowTemplateID ' ] = $ testCase [ ' workflowTemplateID ' ] ;
192+ if ($ workflowTemplateID ) {
193+ $ putPolicy ['persistentWorkflowTemplateID ' ] = $ workflowTemplateID ;
174194 } else {
175195 $ persistentEntry = \Qiniu \entry (
176196 $ bucket ,
@@ -179,14 +199,14 @@ public function testPfopWithUploadPolicy()
179199 array (
180200 'test-pfop/test-pfop-by-upload ' ,
181201 'type ' ,
182- $ testCase [ ' type ' ]
202+ $ type
183203 )
184204 )
185205 );
186206 $ putPolicy ['persistentOps ' ] = 'avinfo|saveas/ ' . $ persistentEntry ;
187207 }
188208
189- if ($ testCase [ ' type ' ] == null ) {
209+ if ($ type == null ) {
190210 unset($ putPolicy ['persistentType ' ]);
191211 }
192212
@@ -206,7 +226,7 @@ public function testPfopWithUploadPolicy()
206226 true
207227 );
208228
209- if (in_array ($ testCase [ ' type ' ] , array (null , 0 , 1 ))) {
229+ if (in_array ($ type , array (null , 0 , 1 ))) {
210230 $ this ->assertNull ($ error );
211231 $ this ->assertNotEmpty ($ ret ['persistentId ' ]);
212232 $ id = $ ret ['persistentId ' ];
@@ -220,15 +240,15 @@ public function testPfopWithUploadPolicy()
220240
221241 $ this ->assertNotNull ($ status );
222242 $ this ->assertNull ($ error );
223- if ($ testCase [ ' type ' ] == 1 ) {
243+ if ($ type == 1 ) {
224244 $ this ->assertEquals (1 , $ status ['type ' ]);
225245 }
226- if ($ testCase [ ' workflowTemplateID ' ] ) {
246+ if ($ workflowTemplateID ) {
227247 // assertStringContainsString when PHPUnit >= 8.0
228248 $ this ->assertTrue (
229249 strpos (
230250 $ status ['taskFrom ' ],
231- $ testCase [ ' workflowTemplateID ' ]
251+ $ workflowTemplateID
232252 ) !== false
233253 );
234254 }
0 commit comments