Skip to content

Commit

Permalink
Use 1.0 test suite and fix base URL to account for the change to HTTP…
Browse files Browse the repository at this point in the history
…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 da8efc5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions Test/W3CTestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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).
*
Expand All @@ -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'},
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "" }
Expand Down

0 comments on commit da8efc5

Please sign in to comment.