From 14973edf06d215b6a7609fd846c7a479202575e2 Mon Sep 17 00:00:00 2001 From: Erayd Date: Tue, 6 Jun 2017 01:33:37 +1200 Subject: [PATCH 1/2] Remove PHPDocumentor & change travis platform for hhvm tests (#429) * Remove dev-time dependency on phpdocumentor due to resolution headaches * Switch distro for hhvm testing to trusty (precise now unsupported) --- .travis.yml | 1 + composer.json | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0bb23a4a..069d8bec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ matrix: - php: 7.1 - php: 'nightly' - php: hhvm + dist: trusty allow_failures: - php: 'nightly' diff --git a/composer.json b/composer.json index 3e26b0f4..009c1485 100644 --- a/composer.json +++ b/composer.json @@ -40,9 +40,8 @@ }, "require-dev": { "json-schema/JSON-Schema-Test-Suite": "1.2.0", - "phpunit/phpunit": "^4.8.22", "friendsofphp/php-cs-fixer": "^2.1", - "phpdocumentor/phpdocumentor": "^2.7" + "phpunit/phpunit": "^4.8.22" }, "autoload": { "psr-4": { "JsonSchema\\": "src/JsonSchema/" } From f120ce1bbfc055421eba41e2a7c890cafa658461 Mon Sep 17 00:00:00 2001 From: Erayd Date: Tue, 6 Jun 2017 01:34:29 +1200 Subject: [PATCH 2/2] Bugfix for #424 - add '?' for query string (#425) Note that this bugfix will cause empty query strings to be dropped (e.g. http://example.com?#blue becomes http://example.com#blue). This is because the '?' character is deliberately not captured as part of the query string, and the testsuite expects to be able to pass an empty query string and *not* have the '?' added for that case. --- src/JsonSchema/Uri/UriResolver.php | 4 ++-- tests/Uri/UriResolverTest.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/JsonSchema/Uri/UriResolver.php b/src/JsonSchema/Uri/UriResolver.php index 7d6e793d..f26046d0 100644 --- a/src/JsonSchema/Uri/UriResolver.php +++ b/src/JsonSchema/Uri/UriResolver.php @@ -61,8 +61,8 @@ public function generate(array $components) . $components['authority'] . $components['path']; - if (array_key_exists('query', $components)) { - $uri .= $components['query']; + if (array_key_exists('query', $components) && strlen($components['query'])) { + $uri .= '?' . $components['query']; } if (array_key_exists('fragment', $components)) { $uri .= '#' . $components['fragment']; diff --git a/tests/Uri/UriResolverTest.php b/tests/Uri/UriResolverTest.php index ea564f65..456b13d3 100644 --- a/tests/Uri/UriResolverTest.php +++ b/tests/Uri/UriResolverTest.php @@ -172,4 +172,22 @@ public function testResolveEmpty() ) ); } + + public function testReversable() + { + $uri = 'scheme://user:password@authority/path?query#fragment'; + $split = $this->resolver->parse($uri); + + // check that the URI was split as expected + $this->assertEquals(array( + 'scheme' => 'scheme', + 'authority' => 'user:password@authority', + 'path' => '/path', + 'query' => 'query', + 'fragment' => 'fragment' + ), $split); + + // check that the recombined URI matches the original input + $this->assertEquals($uri, $this->resolver->generate($split)); + } }