Skip to content

Commit

Permalink
Backports for 5.2.2 (#431)
Browse files Browse the repository at this point in the history
* 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)

* 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.
  • Loading branch information
erayd authored and bighappyface committed Jun 5, 2017
1 parent 429be23 commit 2a42039
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ matrix:
- php: 7.1
- php: 'nightly'
- php: hhvm
dist: trusty
allow_failures:
- php: 'nightly'

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand Down
4 changes: 2 additions & 2 deletions src/JsonSchema/Uri/UriResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
18 changes: 18 additions & 0 deletions tests/Uri/UriResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit 2a42039

Please sign in to comment.