@@ -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 */
@@ -248,6 +248,7 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
248
248
{
249
249
$ expectedError = null ;
250
250
$ expectedWarnings = null ;
251
+ $ headers = null ;
251
252
252
253
// Check if a error must be caught
253
254
if ('catch ' === key ($ operation )) {
@@ -261,6 +262,12 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
261
262
next ($ operation );
262
263
}
263
264
265
+ // Any specific headers to add?
266
+ if ('headers ' === key ($ operation )) {
267
+ $ headers = current ($ operation );
268
+ next ($ operation );
269
+ }
270
+
264
271
$ endpointInfo = explode ('. ' , key ($ operation ));
265
272
$ endpointParams = $ this ->replaceWithContext (current ($ operation ), $ context );
266
273
$ caller = $ this ->client ;
@@ -287,6 +294,10 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa
287
294
$ endpointParams ->client ['future ' ] = true ;
288
295
}
289
296
297
+ if ($ headers != null ) {
298
+ $ endpointParams ->client ['headers ' ] = $ headers ;
299
+ }
300
+
290
301
list ($ method , $ namespace ) = $ this ->mapEndpoint ($ method , $ namespace );
291
302
292
303
if (null !== $ namespace ) {
@@ -629,8 +640,16 @@ public function operationSkip($operation, $lastOperationResult, $testName)
629
640
return $ lastOperationResult ;
630
641
}
631
642
632
- if (property_exists ($ operation , 'features ' ) && !in_array ($ operation ->features , static ::$ supportedFeatures , true )) {
633
- static ::markTestSkipped (sprintf ('Feature(s) %s not supported in test "%s" ' , json_encode ($ operation ->features ), $ testName ));
643
+ if (property_exists ($ operation , 'features ' )) {
644
+ if (is_array ($ operation ->features )) {
645
+ if (count (array_intersect ($ operation ->features , static ::$ supportedFeatures )) != count ($ operation ->features )) {
646
+ static ::markTestSkipped (sprintf ('Feature(s) %s not supported in test "%s" ' , json_encode ($ operation ->features ), $ testName ));
647
+ }
648
+ } else {
649
+ if (!in_array ($ operation ->features , static ::$ supportedFeatures , true )) {
650
+ static ::markTestSkipped (sprintf ('Feature(s) %s not supported in test "%s" ' , json_encode ($ operation ->features ), $ testName ));
651
+ }
652
+ }
634
653
}
635
654
636
655
if (property_exists ($ operation , 'version ' )) {
@@ -844,6 +863,9 @@ private function formatRegex($regex)
844
863
private function splitDocument ($ file , $ path , $ filter = null )
845
864
{
846
865
$ fileContent = file_get_contents ($ file );
866
+ // cleanup some bad comments
867
+ $ fileContent = str_replace ('"# ' , '" # ' , $ fileContent );
868
+
847
869
$ documents = explode ("--- \n" , $ fileContent );
848
870
$ documents = array_filter ($ documents , function ($ item ) {
849
871
return trim ($ item ) !== '' ;
0 commit comments