Skip to content

Commit

Permalink
fix tests on windows (#57)
Browse files Browse the repository at this point in the history
fix tests on windows
  • Loading branch information
vearutop authored Oct 1, 2018
1 parent b603aaa commit f5ce9a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/JSON-Schema-Test-Suite
12 changes: 12 additions & 0 deletions tests/src/PHPUnit/Ref/FileResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function testFileResolver()
function testFileReference()
{
$pathToExternalSchema = __DIR__ . '/../../../resources/remotes/subSchemas.json';
$pathToExternalSchema = $this->preparePath($pathToExternalSchema);
$schemaData = json_decode(<<<JSON
{"\$ref": "file://$pathToExternalSchema#/integer"}
JSON
Expand All @@ -86,6 +87,7 @@ function testFileReference()
function testFileReferenceCapitalized()
{
$pathToExternalSchema = __DIR__ . '/../../../resources/remotes/subSchemas.json';
$pathToExternalSchema = $this->preparePath($pathToExternalSchema);
$schemaData = json_decode(<<<JSON
{"\$ref": "FILE://$pathToExternalSchema#/integer"}
JSON
Expand All @@ -101,6 +103,7 @@ function testFileReferenceCapitalized()
function testFileReferenceRealpath()
{
$pathToExternalSchema = realpath(__DIR__ . '/../../../resources/remotes/subSchemas.json');
$pathToExternalSchema = $this->preparePath($pathToExternalSchema);
$schemaData = json_decode(<<<JSON
{"\$ref": "file://$pathToExternalSchema#/integer"}
JSON
Expand All @@ -117,6 +120,7 @@ function testFileReferenceRealpathWithSpecialCharacters()
{
$pathToExternalSchema = realpath(__DIR__ . '/../../../resources/remotes/#special~characters%directory/subSchemas.json');
$pathToExternalSchema = str_replace('#special~characters%directory', rawurlencode('#special~characters%directory'), $pathToExternalSchema);
$pathToExternalSchema = $this->preparePath($pathToExternalSchema);
$schemaData = json_decode(<<<JSON
{"\$ref": "file://$pathToExternalSchema#/integer"}
JSON
Expand All @@ -132,6 +136,7 @@ function testFileReferenceRealpathWithSpecialCharacters()
function testFileReferenceNoProtocolScheme()
{
$pathToExternalSchema = __DIR__ . '/../../../resources/remotes/subSchemas.json';
$pathToExternalSchema = $this->preparePath($pathToExternalSchema);
$schemaData = json_decode(<<<JSON
{"\$ref": "$pathToExternalSchema#/integer"}
JSON
Expand All @@ -144,4 +149,11 @@ function testFileReferenceNoProtocolScheme()
$schema->in('abc');
}

private function preparePath($path)
{
if (DIRECTORY_SEPARATOR === '\\') {
return str_replace('\\', '/', $path);
}
return $path;
}
}

0 comments on commit f5ce9a1

Please sign in to comment.