Skip to content

Commit aadc597

Browse files
authored
tests: php QA tests run offline (#594)
fises #593
2 parents 5868a43 + 4bdd88c commit aadc597

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tools/src/test/php/json-schema-functional-tests.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ function validateFile(string $file): ?JsonSchema\Errors\ValidationError
9090

9191
// Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used.
9292
// The status 0 is used to terminate the program successfully.
93-
exit(min($errCnt, 254));
93+
exit(min($errCnt, 254));

tools/src/test/php/xml-schema-functional-tests.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
define('TESTSCHEMA_VERSION', getopt('v:')['v']);
1515
define('SCHEMA_DIR', realpath(__DIR__ . '/../../../../schema'));
1616
define('SCHEMA_FILE', SCHEMA_DIR . '/bom-' . TESTSCHEMA_VERSION . '.xsd');
17+
define('SPDX_FILE', SCHEMA_DIR . '/spdx.xsd');
18+
1719
define('TESTDATA_DIR', realpath(__DIR__ . '/../resources/' . TESTSCHEMA_VERSION));
1820

1921
if (empty(TESTSCHEMA_VERSION)) {
@@ -58,7 +60,13 @@ function validateFile(string $file): ?LibXMLError
5860
throw new Exception("failed loading file: $file" . PHP_EOL . libxml_get_last_error()->message);
5961
}
6062

61-
$valid = $doc->schemaValidate(SCHEMA_FILE);
63+
$xsd = str_replace(
64+
'schemaLocation="http://cyclonedx.org/schema/spdx"',
65+
'schemaLocation="file://'. htmlspecialchars(SPDX_FILE, ENT_XML1, 'UTF-8') .'"',
66+
file_get_contents(SCHEMA_FILE)
67+
);
68+
69+
$valid = $doc->schemaValidateSource($xsd, LIBXML_SCHEMA_CREATE);
6270
return $valid
6371
? null
6472
: libxml_get_last_error();
@@ -96,4 +104,4 @@ function validateFile(string $file): ?LibXMLError
96104

97105
// Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used.
98106
// The status 0 is used to terminate the program successfully.
99-
exit(min($errCnt, 254));
107+
exit(min($errCnt, 254));

0 commit comments

Comments
 (0)