summaryrefslogtreecommitdiffstats
path: root/php-justinrainbow-json-schema5-rpm.patch
blob: e354326225ad4dfd7dcce36de9c475cd21293e01 (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	2017-03-23 08:58:50.000000000 +0100
+++ ./bin/validate-json	2017-03-23 09:23:35.797857285 +0100
@@ -6,32 +6,7 @@
  * @author Christian Weiske <christian.weiske@netresearch.de>
  */
 
-/**
- * Dead simple autoloader
- *
- * @param string $className Name of class to load
- *
- * @return void
- */
-function __autoload($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	2017-03-23 08:58:50.000000000 +0100
+++ ./src/JsonSchema/Uri/UriRetriever.php	2017-03-23 09:23:35.797857285 +0100
@@ -323,7 +323,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	2017-03-23 08:58:50.000000000 +0100
+++ ./tests/Uri/UriRetrieverTest.php	2017-03-23 09:28:28.992372836 +0100
@@ -295,7 +295,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);
@@ -304,7 +305,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',
@@ -322,11 +324,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 testJsonSchemaOrgMediaTypeHack()
@@ -365,7 +367,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()