99use function implode ;
1010use function shell_exec ;
1111use function sprintf ;
12+ use function version_compare ;
13+
14+ use const PHP_VERSION ;
1215
1316/**
1417 * @coversNothing
@@ -28,97 +31,188 @@ public function testApplicationRuns(): void
2831 ])
2932 ));
3033
31- self ::assertSame (
32- <<<'EXPECTED_YAML'
33- openapi: 3.0.2
34- info:
35- title: 'Example OpenAPI Definition'
36- description: 'This is the example Description'
37- contact:
38- name: 'Base Author'
39- url: base.example.org
40- email: base-file@example.org
41- license:
42- name: MIT
43- url: 'https://tldrlegal.com/license/mit-license'
44- version: '1.0'
45- servers:
46- -
47- url: 'https://api.base.example.org'
48- description: 'Main Base URL'
49- paths:
50- /ping:
51- get:
52- tags:
53- - 'Base Route'
54- summary: 'Your GET endpoint'
55- description: 'Description of Ping'
56- operationId: get-ping
57- parameters:
58- -
59- name: responseWith
60- in: query
61- description: 'response with this message'
62- schema:
63- maxLength: 20
64- minLength: 0
65- type: string
66- responses:
67- '200':
68- description: OK
69- content:
70- application/json:
71- schema:
72- required:
73- - response
74- type: object
75- properties:
76- response:
77- type: string
78- '400':
79- description: 'Bad Request'
80- content:
81- application/problem+json:
34+ if (version_compare (PHP_VERSION , '8.1.0 ' , '>= ' )) {
35+ $ expected = <<<'EXPECTED_YAML'
36+ openapi: 3.0.2
37+ info:
38+ title: 'Example OpenAPI Definition'
39+ description: 'This is the example Description'
40+ contact:
41+ name: 'Base Author'
42+ url: base.example.org
43+ email: base-file@example.org
44+ license:
45+ name: MIT
46+ url: 'https://tldrlegal.com/license/mit-license'
47+ version: '1.0'
48+ servers:
49+ -
50+ url: 'https://api.base.example.org'
51+ description: 'Main Base URL'
52+ paths:
53+ /ping:
54+ get:
55+ tags:
56+ - 'Base Route'
57+ summary: 'Your GET endpoint'
58+ description: 'Description of Ping'
59+ operationId: get-ping
60+ parameters:
61+ -
62+ name: responseWith
63+ in: query
64+ description: 'response with this message'
8265 schema:
83- title: ProblemResponse
84- required:
85- - type
86- - title
87- type: object
88- properties:
89- type:
90- type: string
91- description: 'type of the problem'
92- example: ValidationError
93- title:
94- type: string
95- example: 'Your request parameters didn''t validate.'
96- description: 'Default Problem Response'
97- post:
98- summary: 'Your POST endpoint'
99- description: 'Description of post Ping'
100- operationId: post-ping
101- responses:
102- '200':
103- description: OK
104- content:
105- application/json:
66+ maxLength: 20
67+ minLength: 0
68+ type: string
69+ responses:
70+ '200':
71+ description: OK
72+ content:
73+ application/json:
74+ schema:
75+ required:
76+ - response
77+ type: object
78+ properties:
79+ response:
80+ type: string
81+ '400':
82+ description: 'Bad Request'
83+ content:
84+ application/problem+json:
85+ schema:
86+ title: ProblemResponse
87+ required:
88+ - type
89+ - title
90+ type: object
91+ properties:
92+ type:
93+ type: string
94+ description: 'type of the problem'
95+ example: ValidationError
96+ title:
97+ type: string
98+ example: "Your request parameters didn't validate."
99+ description: 'Default Problem Response'
100+ post:
101+ summary: 'Your POST endpoint'
102+ description: 'Description of post Ping'
103+ operationId: post-ping
104+ responses:
105+ '200':
106+ description: OK
107+ content:
108+ application/json:
109+ schema:
110+ required:
111+ - response
112+ type: object
113+ properties:
114+ response:
115+ type: string
116+ components:
117+ schemas: { }
118+ security: []
119+ tags:
120+ -
121+ name: Base
122+
123+ EXPECTED_YAML;
124+ } else {
125+ $ expected = <<<'EXPECTED_YAML'
126+ openapi: 3.0.2
127+ info:
128+ title: 'Example OpenAPI Definition'
129+ description: 'This is the example Description'
130+ contact:
131+ name: 'Base Author'
132+ url: base.example.org
133+ email: base-file@example.org
134+ license:
135+ name: MIT
136+ url: 'https://tldrlegal.com/license/mit-license'
137+ version: '1.0'
138+ servers:
139+ -
140+ url: 'https://api.base.example.org'
141+ description: 'Main Base URL'
142+ paths:
143+ /ping:
144+ get:
145+ tags:
146+ - 'Base Route'
147+ summary: 'Your GET endpoint'
148+ description: 'Description of Ping'
149+ operationId: get-ping
150+ parameters:
151+ -
152+ name: responseWith
153+ in: query
154+ description: 'response with this message'
106155 schema:
107- required:
108- - response
109- type: object
110- properties:
111- response:
112- type: string
113- components:
114- schemas: []
115- security: []
116- tags:
117- -
118- name: Base
156+ maxLength: 20
157+ minLength: 0
158+ type: string
159+ responses:
160+ '200':
161+ description: OK
162+ content:
163+ application/json:
164+ schema:
165+ required:
166+ - response
167+ type: object
168+ properties:
169+ response:
170+ type: string
171+ '400':
172+ description: 'Bad Request'
173+ content:
174+ application/problem+json:
175+ schema:
176+ title: ProblemResponse
177+ required:
178+ - type
179+ - title
180+ type: object
181+ properties:
182+ type:
183+ type: string
184+ description: 'type of the problem'
185+ example: ValidationError
186+ title:
187+ type: string
188+ example: 'Your request parameters didn''t validate.'
189+ description: 'Default Problem Response'
190+ post:
191+ summary: 'Your POST endpoint'
192+ description: 'Description of post Ping'
193+ operationId: post-ping
194+ responses:
195+ '200':
196+ description: OK
197+ content:
198+ application/json:
199+ schema:
200+ required:
201+ - response
202+ type: object
203+ properties:
204+ response:
205+ type: string
206+ components:
207+ schemas: { }
208+ security: []
209+ tags:
210+ -
211+ name: Base
212+
213+ EXPECTED_YAML;
214+ }
119215
120- EXPECTED_YAML,
121- $ output
122- );
216+ self ::assertSame ($ expected , $ output );
123217 }
124218}
0 commit comments