@@ -26,10 +26,13 @@ class ActionTest
2626{
2727 const TEMPLATE_ENDPOINT = __DIR__ . '/template/test/endpoint ' ;
2828 const TEMPLATE_ENDPOINT_TRY_CATCH = __DIR__ . '/template/test/endpoint-try-catch ' ;
29+ const TEMPLATE_ENDPOINT_TRY_CATCH_ARRAY = __DIR__ . '/template/test/endpoint-try-catch-array ' ;
2930 const TEMPLATE_MATCH_EQUAL = __DIR__ . '/template/test/match-equal ' ;
3031 const TEMPLATE_MATCH_REGEX = __DIR__ . '/template/test/match-regex ' ;
3132 const TEMPLATE_IS_FALSE = __DIR__ . '/template/test/is-false ' ;
33+ const TEMPLATE_IS_FALSE_RESPONSE = __DIR__ . '/template/test/is-false-response ' ;
3234 const TEMPLATE_IS_TRUE = __DIR__ . '/template/test/is-true ' ;
35+ const TEMPLATE_IS_TRUE_RESPONSE = __DIR__ . '/template/test/is-true-response ' ;
3336 const TEMPLATE_IS_NULL = __DIR__ . '/template/test/is-null ' ;
3437 const TEMPLATE_LENGTH = __DIR__ . '/template/test/length ' ;
3538 const TEMPLATE_SKIP_VERSION = __DIR__ . '/template/test/skip-version ' ;
@@ -103,7 +106,6 @@ private function do(array $actions): string
103106 // headers
104107 if (!empty ($ this ->headers )) {
105108 $ vars [':headers ' ] = $ this ->formatHeaders ($ this ->headers );
106- $ vars [':reset-headers ' ] = $ this ->resetHeaders ($ this ->headers );
107109 $ this ->headers = [];
108110 }
109111 // Check if {} (new stdClass) is the parameter of an endpoint
@@ -123,6 +125,9 @@ private function do(array $actions): string
123125 // ignore client parameter
124126 if (isset ($ this ->clientParams ['ignore ' ])) {
125127 $ vars [':code ' ] = $ this ->clientParams ['ignore ' ];
128+ if (is_array ($ vars [':code ' ])) {
129+ return YamlTests::render (self ::TEMPLATE_ENDPOINT_TRY_CATCH_ARRAY , $ vars );
130+ }
126131 return YamlTests::render (self ::TEMPLATE_ENDPOINT_TRY_CATCH , $ vars );
127132 }
128133 return YamlTests::render (self ::TEMPLATE_ENDPOINT , $ vars );
@@ -274,9 +279,20 @@ private function match(array $actions)
274279 ($ this ->phpUnitVersion > 8 ) ? (self ::TEMPLATE_PHPUNIT9_MATCH_REGEX ) : (self ::TEMPLATE_MATCH_REGEX ),
275280 $ vars
276281 );
282+ } elseif (is_array ($ expected )) {
283+ if ($ vars [':value ' ] === '$response ' ) {
284+ $ vars [':value ' ] = '$response->asArray() ' ;
285+ }
286+ } elseif (is_bool ($ expected )) {
287+ if ($ vars [':value ' ] === '$response ' ) {
288+ $ vars [':value ' ] = '$response->asBool() ' ;
289+ }
277290 }
278291 if ($ expected instanceof stdClass && empty (get_object_vars ($ expected ))) {
279292 $ vars [':expected ' ] = '[] ' ;
293+ if ($ vars [':value ' ] === '$response ' ) {
294+ $ vars [':value ' ] = '$response->asArray() ' ;
295+ }
280296 }
281297 return YamlTests::render (self ::TEMPLATE_MATCH_EQUAL , $ vars );
282298 }
@@ -286,6 +302,9 @@ private function is_true(string $value)
286302 $ vars = [
287303 ':value ' => $ this ->convertResponseField ($ value )
288304 ];
305+ if ($ vars [':value ' ] === '$response ' ) {
306+ return YamlTests::render (self ::TEMPLATE_IS_TRUE_RESPONSE , $ vars );
307+ }
289308 return YamlTests::render (self ::TEMPLATE_IS_TRUE , $ vars );
290309 }
291310
@@ -294,6 +313,9 @@ private function is_false(string $value)
294313 $ vars = [
295314 ':value ' => $ this ->convertResponseField ($ value )
296315 ];
316+ if ($ vars [':value ' ] === '$response ' ) {
317+ return YamlTests::render (self ::TEMPLATE_IS_FALSE_RESPONSE , $ vars );
318+ }
297319 return YamlTests::render (self ::TEMPLATE_IS_FALSE , $ vars );
298320 }
299321
0 commit comments