Skip to content

Commit 15ef5f6

Browse files
committed
Add more assertions in tests and refactor
1 parent 98b3ef3 commit 15ef5f6

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/spec/SecurityRequirement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected function performValidation()
4444

4545
public function getSerializableData()
4646
{
47+
parent::getSerializableData();
4748
return $this->_securityRequirement;
4849
}
4950
}

src/spec/SecurityRequirements.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ public function __construct(array $data)
2323
{
2424
parent::__construct($data);
2525

26-
$read = true;
2726
foreach ($data as $index => $value) {
2827
if (is_numeric($index)) { // read
29-
$requirements = $value;
3028
$this->_securityRequirements[array_keys($value)[0]] = new SecurityRequirement(array_values($value)[0]);
3129
} else { // write
32-
$read = false;
33-
$requirements = $data;
3430
$this->_securityRequirements[$index] = $value;
3531
}
3632
}
@@ -55,6 +51,7 @@ protected function attributes(): array
5551
*/
5652
protected function performValidation()
5753
{
54+
// TODO
5855
}
5956

6057
/**
@@ -64,6 +61,8 @@ protected function performValidation()
6461
*/
6562
public function getSerializableData()
6663
{
64+
parent::getSerializableData();
65+
6766
$data = [];
6867
foreach ($this->_securityRequirements ?? [] as $name => $securityRequirement) {
6968
/** @var SecurityRequirement $securityRequirement */

tests/WriterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public function testSecurityAtPathOperationLevel()
255255
);
256256
}
257257

258+
// TODO
258259
// public function testSecurityAtGlobalLevel()
259260
// {
260261
// $openapi = $this->createOpenAPI([

tests/spec/OperationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function testRead()
7979

8080
$this->assertInstanceOf(\cebe\openapi\spec\Responses::class, $operation->responses);
8181

82+
$this->assertCount(1, $operation->security->getRequirements());
8283
$this->assertInstanceOf(\cebe\openapi\spec\SecurityRequirements::class, $operation->security);
8384
$this->assertInstanceOf(\cebe\openapi\spec\SecurityRequirement::class, $operation->security->getRequirement('petstore_auth'));
8485
$this->assertCount(2, $operation->security->getRequirement('petstore_auth')->getSerializableData());

0 commit comments

Comments
 (0)