@@ -58,6 +58,56 @@ public function only_specified_strategies_are_loaded()
58
58
$ this ->assertFalse (EmptyStrategy2::$ called );
59
59
}
60
60
61
+ /** @test */
62
+ public function supports_overrides ()
63
+ {
64
+ $ config = [
65
+ 'strategies ' => [
66
+ 'headers ' => [
67
+ DummyHeaderStrategy::class,
68
+ [
69
+ 'overrides ' ,
70
+ ['Content-Type ' => 'application/xml ' ],
71
+ ]
72
+ ],
73
+ 'bodyParameters ' => [],
74
+ 'responses ' => [], // Making this empty so the Laravel-dependent strategies are not called
75
+ ],
76
+ ];
77
+
78
+ $ endpointData = $ this ->processRoute ($ config );
79
+
80
+ $ this ->assertEquals ([
81
+ 'Accept ' => 'application/form-data ' ,
82
+ 'Content-Type ' => 'application/xml ' ,
83
+ ], $ endpointData ->headers );
84
+ }
85
+
86
+
87
+ /** @test */
88
+ public function supports_strategy_tuples ()
89
+ {
90
+ $ config = [
91
+ 'strategies ' => [
92
+ 'headers ' => [
93
+ [
94
+ DummyHeaderStrategy::class,
95
+ ['use_this_content_type ' => 'text/plain ' ],
96
+ ]
97
+ ],
98
+ 'bodyParameters ' => [],
99
+ 'responses ' => [], // Making this empty so the Laravel-dependent strategies are not called
100
+ ],
101
+ ];
102
+
103
+ $ endpointData = $ this ->processRoute ($ config );
104
+
105
+ $ this ->assertEquals ([
106
+ 'Accept ' => 'application/form-data ' ,
107
+ 'Content-Type ' => 'text/plain ' ,
108
+ ], $ endpointData ->headers );
109
+ }
110
+
61
111
/** @test */
62
112
public function responses_from_different_strategies_get_added ()
63
113
{
@@ -217,6 +267,17 @@ public function __invoke(ExtractedEndpointData $endpointData, array $routeRules
217
267
}
218
268
}
219
269
270
+ class DummyHeaderStrategy extends Strategy
271
+ {
272
+ public function __invoke (ExtractedEndpointData $ endpointData , array $ settings = []): ?array
273
+ {
274
+ return [
275
+ 'Accept ' => 'application/form-data ' ,
276
+ 'Content-Type ' => $ settings ['use_this_content_type ' ] ?? 'application/form-data ' ,
277
+ ];
278
+ }
279
+ }
280
+
220
281
class NotDummyMetadataStrategy extends Strategy
221
282
{
222
283
public static $ called = false ;
0 commit comments