diff -up ./bin/validate-json.rpm ./bin/validate-json --- ./bin/validate-json.rpm 2019-09-26 09:03:49.371018279 +0200 +++ ./bin/validate-json 2019-09-26 09:06:21.033483985 +0200 @@ -6,32 +6,7 @@ * @author Christian Weiske */ -/** - * Dead simple autoloader - * - * @param string $className Name of class to load - * - * @return void - */ -spl_autoload_register(function ($className) -{ - $className = ltrim($className, '\\'); - $fileName = ''; - if ($lastNsPos = strrpos($className, '\\')) { - $namespace = substr($className, 0, $lastNsPos); - $className = substr($className, $lastNsPos + 1); - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; - } - $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - if (stream_resolve_include_path($fileName)) { - require_once $fileName; - } -}); - -// support running this tool from git checkout -if (is_dir(__DIR__ . '/../src/JsonSchema')) { - set_include_path(__DIR__ . '/../src' . PATH_SEPARATOR . get_include_path()); -} +require_once '/usr/share/php/JsonSchema5/autoload.php'; $arOptions = array(); $arArgs = array(); diff -up ./src/JsonSchema/Uri/UriRetriever.php.rpm ./src/JsonSchema/Uri/UriRetriever.php --- ./src/JsonSchema/Uri/UriRetriever.php.rpm 2019-09-26 09:03:13.000000000 +0200 +++ ./src/JsonSchema/Uri/UriRetriever.php 2019-09-26 09:03:49.371018279 +0200 @@ -342,7 +342,8 @@ class UriRetriever implements BaseUriRet } // translate references to local files within the json-schema package - $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri); + $path = (getenv('BUILDROOT_SCHEMA')?:'') . '/usr/share/php-justinrainbow-json-schema5'; + $uri = preg_replace('|^package://|', sprintf('file://%s/', $path), $uri); return $uri; } diff -up ./tests/Uri/UriRetrieverTest.php.rpm ./tests/Uri/UriRetrieverTest.php --- ./tests/Uri/UriRetrieverTest.php.rpm 2019-09-26 09:03:13.000000000 +0200 +++ ./tests/Uri/UriRetrieverTest.php 2019-09-26 09:03:49.372018275 +0200 @@ -296,7 +296,8 @@ EOF; public function testPackageURITranslation() { $retriever = new UriRetriever(); - $root = sprintf('file://%s/', realpath(__DIR__ . '/../..')); + $path = (getenv('BUILDROOT_SCHEMA')?:'') . '/usr/share/php-justinrainbow-json-schema5'; + $root = sprintf('file://%s/', $path); $uri = $retriever->translate('package://foo/bar.json'); $this->assertEquals("${root}foo/bar.json", $uri); @@ -305,7 +306,8 @@ EOF; public function testDefaultDistTranslations() { $retriever = new UriRetriever(); - $root = sprintf('file://%s/dist/schema/', realpath(__DIR__ . '/../..')); + $path = (getenv('BUILDROOT_SCHEMA')?:'') . '/usr/share/php-justinrainbow-json-schema5'; + $root = sprintf('file://%s/dist/schema/', $path); $this->assertEquals( $root . 'json-schema-draft-03.json', @@ -323,11 +325,12 @@ EOF; $retriever = new UriRetriever(); // load schema from package - $schema = $retriever->retrieve('package://tests/fixtures/foobar.json'); + $schema = $retriever->retrieve('file://' . dirname(__DIR__) . '/fixtures/foobar.json'); $this->assertNotFalse($schema); // check that the schema was loaded & processed correctly - $this->assertEquals('454f423bd7edddf0bc77af4130ed9161', md5(json_encode($schema))); + $schema->id = 'foo'; + $this->assertEquals('c2ef5714b639cea176fdeeafe418aa09', md5(json_encode($schema))); } public function testInvalidContentTypeEndpointsDefault() @@ -389,7 +392,7 @@ EOF; 'JsonSchema\Exception\JsonDecodingException', 'JSON syntax is malformed' ); - $schema = $retriever->retrieve('package://tests/fixtures/bad-syntax.json'); + $schema = $retriever->retrieve('file://' . dirname(__DIR__) . '/fixtures/bad-syntax.json'); } public function testGenerateURI()