Skip to content

Commit 19e68bf

Browse files
committed
Add more test
1 parent 15ef5f6 commit 19e68bf

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

tests/WriterTest.php

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -255,46 +255,46 @@ public function testSecurityAtPathOperationLevel()
255255
);
256256
}
257257

258-
// TODO
259-
// public function testSecurityAtGlobalLevel()
260-
// {
261-
// $openapi = $this->createOpenAPI([
262-
// 'components' => new Components([
263-
// 'securitySchemes' => [
264-
// 'BearerAuth' => new SecurityScheme([
265-
// 'type' => 'http',
266-
// 'scheme' => 'bearer',
267-
// 'bearerFormat' => 'AuthToken and JWT Format' # optional, arbitrary value for documentation purposes
268-
// ])
269-
// ],
270-
// ]),
271-
// 'security' => [
272-
// 'BearerAuth' => new SecurityRequirement([])
273-
// ],
274-
// 'paths' => [],
275-
// ]);
276-
//
277-
// $yaml = \cebe\openapi\Writer::writeToYaml($openapi);
278-
//
279-
//
280-
// $this->assertEquals(preg_replace('~\R~', "\n", <<<YAML
281-
//openapi: 3.0.0
282-
//info:
283-
// title: 'Test API'
284-
// version: 1.0.0
285-
//paths: { }
286-
//components:
287-
// securitySchemes:
288-
// BearerAuth:
289-
// type: http
290-
// scheme: bearer
291-
// bearerFormat: 'AuthToken and JWT Format'
292-
//security:
293-
// BearerAuth: { }
294-
//
295-
//YAML
296-
// ),
297-
// $yaml
298-
// );
299-
// }
258+
public function testSecurityAtGlobalLevel()
259+
{
260+
$openapi = $this->createOpenAPI([
261+
'components' => new Components([
262+
'securitySchemes' => [
263+
'BearerAuth' => new SecurityScheme([
264+
'type' => 'http',
265+
'scheme' => 'bearer',
266+
'bearerFormat' => 'AuthToken and JWT Format' # optional, arbitrary value for documentation purposes
267+
])
268+
],
269+
]),
270+
'security' => new SecurityRequirements([
271+
'BearerAuth' => new SecurityRequirement([])
272+
]),
273+
'paths' => [],
274+
]);
275+
276+
$yaml = \cebe\openapi\Writer::writeToYaml($openapi);
277+
278+
279+
$this->assertEquals(preg_replace('~\R~', "\n", <<<YAML
280+
openapi: 3.0.0
281+
info:
282+
title: 'Test API'
283+
version: 1.0.0
284+
paths: { }
285+
components:
286+
securitySchemes:
287+
BearerAuth:
288+
type: http
289+
scheme: bearer
290+
bearerFormat: 'AuthToken and JWT Format'
291+
security:
292+
-
293+
BearerAuth: []
294+
295+
YAML
296+
),
297+
$yaml
298+
);
299+
}
300300
}

0 commit comments

Comments
 (0)