Skip to content

Commit c759198

Browse files
committed
Fixed VectorTile YAML tests quoting y
1 parent 275de8d commit c759198

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

util/YamlTests.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,31 @@ public function __construct(string $testDir, string $testOutput, string $esVersi
126126
self::$minorEsVersion = sprintf("%s.%s", $major, $minor);
127127
}
128128

129+
/**
130+
* @see https://www.php.net/manual/en/function.yaml-parse-file.php#124980
131+
*/
132+
private function quoteYInYamlFile(string $file)
133+
{
134+
return str_replace (' y: ', ' "y": ', file_get_contents($file));
135+
}
136+
129137
private function getAllTests(string $dir): array
130138
{
131139
$it = new RecursiveDirectoryIterator($dir);
132140
$parsed = [];
133141
// Iterate over the Yaml test files
134142
foreach (new RecursiveIteratorIterator($it) as $file) {
135143
if ($file->getExtension() === 'yml') {
136-
$test = yaml_parse_file($file->getPathname(), -1, $ndocs, [
137-
YAML_MAP_TAG => function($value, $tag, $flags) {
138-
return empty($value) ? new stdClass : $value;
139-
}
140-
]);
144+
$test = yaml_parse(
145+
$this->quoteYInYamlFile($file->getPathname()),
146+
-1,
147+
$ndocs,
148+
[
149+
YAML_MAP_TAG => function($value, $tag, $flags) {
150+
return empty($value) ? new stdClass : $value;
151+
}
152+
]
153+
);
141154
if (false === $test) {
142155
throw new Exception(sprintf(
143156
"YAML parse error file %s",

0 commit comments

Comments
 (0)