summaryrefslogtreecommitdiffstats
path: root/php-justinrainbow-json-schema5-rpm.patch
blob: eb8e536f1c65e794c4fbabbee5efe575ddb21fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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 <christian.weiske@netresearch.de>
  */
 
-/**
- * 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()