@@ -42,7 +42,7 @@ class YamlRunnerTest extends \PHPUnit_Framework_TestCase
42
42
43
43
/** @var array A list of supported features */
44
44
private static $ supportedFeatures = [
45
- 'stash_in_path ' , 'warnings '
45
+ 'stash_in_path ' , 'warnings ' , ' headers ' , ' yaml '
46
46
];
47
47
48
48
/** @var array A mapping for endpoint when there is a reserved keywords for the method / namespace name */
@@ -252,6 +252,7 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
252
252
{
253
253
$ expectedError = null ;
254
254
$ expectedWarnings = null ;
255
+ $ headers = null ;
255
256
256
257
// Check if a error must be caught
257
258
if ('catch ' === key ($ operation )) {
@@ -265,6 +266,12 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
265
266
next ($ operation );
266
267
}
267
268
269
+ // Any specific headers to add?
270
+ if ('headers ' === key ($ operation )) {
271
+ $ headers = current ($ operation );
272
+ next ($ operation );
273
+ }
274
+
268
275
$ endpointInfo = explode ('. ' , key ($ operation ));
269
276
$ endpointParams = $ this ->replaceWithContext (current ($ operation ), $ context );
270
277
$ caller = $ this ->client ;
@@ -291,6 +298,10 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
291
298
$ endpointParams ->client ['future ' ] = true ;
292
299
}
293
300
301
+ if ($ headers != null ) {
302
+ $ endpointParams ->client ['headers ' ] = $ headers ;
303
+ }
304
+
294
305
list ($ method , $ namespace ) = $ this ->mapEndpoint ($ method , $ namespace );
295
306
296
307
if (null !== $ namespace ) {
@@ -633,8 +644,16 @@ public function operationSkip($operation, $lastOperationResult, $testName)
633
644
return $ lastOperationResult ;
634
645
}
635
646
636
- if (property_exists ($ operation , 'features ' ) && !in_array ($ operation ->features , static ::$ supportedFeatures , true )) {
637
- static ::markTestSkipped (sprintf ('Feature(s) %s not supported in test "%s" ' , json_encode ($ operation ->features ), $ testName ));
647
+ if (property_exists ($ operation , 'features ' )) {
648
+ if (is_array ($ operation ->features )) {
649
+ if (count (array_intersect ($ operation ->features , static ::$ supportedFeatures )) != count ($ operation ->features )) {
650
+ static ::markTestSkipped (sprintf ('Feature(s) %s not supported in test "%s" ' , json_encode ($ operation ->features ), $ testName ));
651
+ }
652
+ } else {
653
+ if (!in_array ($ operation ->features , static ::$ supportedFeatures , true )) {
654
+ static ::markTestSkipped (sprintf ('Feature(s) %s not supported in test "%s" ' , json_encode ($ operation ->features ), $ testName ));
655
+ }
656
+ }
638
657
}
639
658
640
659
if (property_exists ($ operation , 'version ' )) {
@@ -848,6 +867,9 @@ private function formatRegex($regex)
848
867
private function splitDocument ($ file , $ path , $ filter = null )
849
868
{
850
869
$ fileContent = file_get_contents ($ file );
870
+ // cleanup some bad comments
871
+ $ fileContent = str_replace ('"# ' , '" # ' , $ fileContent );
872
+
851
873
$ documents = explode ("--- \n" , $ fileContent );
852
874
$ documents = array_filter ($ documents , function ($ item ) {
853
875
return trim ($ item ) !== '' ;
0 commit comments