Skip to content

Commit c9736d8

Browse files
committed
Fix failing tests in CI
1 parent 19fabbc commit c9736d8

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# php-openapi
22

3+
TODO docs related to issue 242, 238
4+
35
Read and write [OpenAPI](https://www.openapis.org/) 3.0.x YAML and JSON files and make the content accessible in PHP objects.
46

57
It also provides a CLI tool for validating and converting OpenAPI 3.0.x Description files.

src/spec/SecurityRequirements.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function getSerializableData()
6969
$data = [];
7070

7171
foreach ($this->_securityRequirements ?? [] as $outerIndex => $content) {
72-
7372
if (is_string($outerIndex)) {
7473
$data[] = [$outerIndex => $content->getSerializableData()];
7574
} elseif (is_numeric($outerIndex)) {

tests/spec/OpenApiTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ public function assertAllInstanceOf($className, $array)
8888
}
8989
}
9090

91+
public function assertFewInstanceOf($className, $array)
92+
{
93+
foreach($array as $k => $v) {
94+
if (is_numeric($k) && $v === []) { # https://github.com/cebe/php-openapi/issues/238
95+
continue;
96+
}
97+
98+
if (is_array($v)) {
99+
$this->{__FUNCTION__}($className, $v);
100+
} else {
101+
$this->assertInstanceOf($className, $v, "Asserting that item with key '$k' is instance of $className");
102+
}
103+
}
104+
}
105+
91106
public function specProvider()
92107
{
93108
// examples from https://github.com/OAI/OpenAPI-Specification/tree/master/examples/v3.0
@@ -222,7 +237,7 @@ public function testSpecs($openApiFile)
222237

223238
// security
224239
$openapi->security !== null && $this->assertInstanceOf(\cebe\openapi\spec\SecurityRequirements::class, $openapi->security);
225-
$openapi->security !== null && $this->assertAllInstanceOf(\cebe\openapi\spec\SecurityRequirement::class, $openapi->security->getRequirements());
240+
$openapi->security !== null && $this->assertFewInstanceOf(\cebe\openapi\spec\SecurityRequirement::class, $openapi->security->getRequirements());
226241

227242
// tags
228243
$this->assertAllInstanceOf(\cebe\openapi\spec\Tag::class, $openapi->tags);

0 commit comments

Comments
 (0)