From da8efc590273f0420e79cb110778508875690bde Mon Sep 17 00:00:00 2001 From: Markus Lanthaler Date: Sun, 28 Jan 2018 13:04:10 +0100 Subject: [PATCH] Use 1.0 test suite and fix base URL to account for the change to HTTPS 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 --- .travis.yml | 5 ++++- Test/W3CTestSuiteTest.php | 22 ++++++++++++++++++---- composer.json | 3 ++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 492d0d5..7a9ffb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Test/W3CTestSuiteTest.php b/Test/W3CTestSuiteTest.php index 8e0cecd..fdfcb6a 100644 --- a/Test/W3CTestSuiteTest.php +++ b/Test/W3CTestSuiteTest.php @@ -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'}, diff --git a/composer.json b/composer.json index 5f73ae9..6c01741 100644 --- a/composer.json +++ b/composer.json @@ -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": "" }