Skip to content

Commit

Permalink
fix test for PHP 7.1
Browse files Browse the repository at this point in the history
fixes #91
  • Loading branch information
cebe committed Dec 23, 2020
1 parent dd8770b commit 9f10d43
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions tests/spec/ReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ public function testTransitiveReferenceOverTwoFiles()

$yaml = \cebe\openapi\Writer::writeToYaml($openapi);

$this->assertEquals(
<<<YAML
$expected = <<<YAML
openapi: 3.0.0
info:
title: 'Ref Example'
Expand All @@ -441,8 +440,14 @@ public function testTransitiveReferenceOverTwoFiles()
'200':
description: 'return a cat'
YAML
, $yaml, $yaml);
YAML;
if (PHP_VERSION_ID < 70200) {
// PHP <7.2 returns numeric properties in yaml maps as integer, since 7.2 these are string
// probably related to https://www.php.net/manual/de/migration72.incompatible.php#migration72.incompatible.object-array-casts
$this->assertEquals(str_replace("'200':", "200:", $expected), $yaml, $yaml);
} else {
$this->assertEquals($expected, $yaml, $yaml);
}
}

public function testResolveRelativePathInline()
Expand All @@ -451,8 +456,7 @@ public function testResolveRelativePathInline()

$yaml = \cebe\openapi\Writer::writeToYaml($openapi);

$this->assertEquals(
<<<YAML
$expected = <<<YAML
openapi: 3.0.3
info:
title: 'Link Example'
Expand Down Expand Up @@ -487,8 +491,14 @@ public function testResolveRelativePathInline()
\$ref: '#/components/schemas/Pet'
description: 'A Cat'
YAML
, $yaml, $yaml);
YAML;
if (PHP_VERSION_ID < 70200) {
// PHP <7.2 returns numeric properties in yaml maps as integer, since 7.2 these are string
// probably related to https://www.php.net/manual/de/migration72.incompatible.php#migration72.incompatible.object-array-casts
$this->assertEquals(str_replace("'200':", "200:", $expected), $yaml, $yaml);
} else {
$this->assertEquals($expected, $yaml, $yaml);
}
}

public function testResolveRelativePathAll()
Expand All @@ -497,8 +507,7 @@ public function testResolveRelativePathAll()

$yaml = \cebe\openapi\Writer::writeToYaml($openapi);

$this->assertEquals(
<<<YAML
$expected = <<<YAML
openapi: 3.0.3
info:
title: 'Link Example'
Expand Down Expand Up @@ -550,8 +559,14 @@ public function testResolveRelativePathAll()
description: 'A Pet'
description: 'A Cat'
YAML
, $yaml, $yaml);
YAML;
if (PHP_VERSION_ID < 70200) {
// PHP <7.2 returns numeric properties in yaml maps as integer, since 7.2 these are string
// probably related to https://www.php.net/manual/de/migration72.incompatible.php#migration72.incompatible.object-array-casts
$this->assertEquals(str_replace("'200':", "200:", $expected), $yaml, $yaml);
} else {
$this->assertEquals($expected, $yaml, $yaml);
}
}

}

0 comments on commit 9f10d43

Please sign in to comment.