Permalink
Browse files

Use 1.0 test suite and fix base URL to account for the change to HTTP…

…S on json-ld.org

Fix Travis test config:
 - run PHP 5.3 tests on Travis on Precise as it isn't supported on Trusty
 - stop checking exception messages (PHPUnit's behavior changed)
 - fix PHPUnit version
 - run tests also on PHP 7.1
  • Loading branch information...
lanthaler committed Jan 28, 2018
1 parent f9dfe18 commit da8efc590273f0420e79cb110778508875690bde
Showing with 24 additions and 6 deletions.
  1. +4 −1 .travis.yml
  2. +18 −4 Test/W3CTestSuiteTest.php
  3. +2 −1 composer.json
@@ -1,17 +1,20 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
matrix:
fast_finish: true
allow_failures:
- php: hhvm
include:
- php: 5.3
dist: precise
before_script:
- composer install
@@ -172,14 +172,14 @@ public function flattenProvider()
public function testRemoteDocumentLoading($name, $test, $options)
{
if (in_array('jld:NegativeEvaluationTest', $test->{'@type'})) {
$this->setExpectedException('ML\JsonLD\Exception\JsonLdException', '', $test->{'expect'});
$this->setExpectedException('ML\JsonLD\Exception\JsonLdException', null, $test->{'expect'});
} else {
$expected = json_decode(file_get_contents($this->basedir . $test->{'expect'}));
$expected = json_decode($this->replaceBaseUrl(file_get_contents($this->basedir . $test->{'expect'})));
}
unset($options->base);
$result = JsonLD::expand($this->baseurl . $test->{'input'}, $options);
$result = JsonLD::expand($this->replaceBaseUrl($this->baseurl . $test->{'input'}), $options);
if (isset($expected)) {
$this->assertJsonEquals($expected, $result);
@@ -197,6 +197,20 @@ public function remoteDocumentLoadingProvider()
);
}
/**
* Replaces the base URL 'http://json-ld.org/' with 'https://json-ld.org:443/'.
*
* The test location of the test suite has been changed as the site has been
* updated to use HTTPS everywhere.
*
* @param string $input The input string.
*
* @return string The input string with all occurrences of the old base URL replaced with the new HTTPS-based one.
*/
private function replaceBaseUrl($input) {
return str_replace('http://json-ld.org/', 'https://json-ld.org:443/', $input);
}
/**
* Tests errors (uses flattening).
*
@@ -209,7 +223,7 @@ public function remoteDocumentLoadingProvider()
*/
public function testError($name, $test, $options)
{
$this->setExpectedException('ML\JsonLD\Exception\JsonLdException', '', $test->{'expect'});
$this->setExpectedException('ML\JsonLD\Exception\JsonLdException', null, $test->{'expect'});
JsonLD::flatten(
$this->basedir . $test->{'input'},
@@ -19,7 +19,8 @@
"ml/iri": "^1.1.1"
},
"require-dev": {
"json-ld/tests": "@dev"
"json-ld/tests": "1.0",
"phpunit/phpunit": "^4"
},
"autoload": {
"psr-0": { "ML\\JsonLD": "" }

0 comments on commit da8efc5

Please sign in to comment.