forked from garycourt/JSV
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Greg Beaver
authored and
Greg Beaver
committed
Jul 28, 2011
1 parent
3eb5cdd
commit f0dd303
Showing
7 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--TEST-- | ||
JsonSchema: URI - resolve (1) with scheme | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/setup.php.inc'; | ||
$base = "http://a/b/c/d;p?q"; | ||
|
||
$test->assertEquals('g:h', $uri->resolve($base, 'g:h'), 'g:h'); | ||
$test->assertEquals('http://a/b/c/g', $uri->resolve($base, 'g'), 'g'); | ||
$test->assertEquals('http://a/b/c/g', $uri->resolve($base, './g'), './g'); | ||
$test->assertEquals('http://a/b/c/g/', $uri->resolve($base, 'g/'), 'g/'); | ||
$test->assertEquals('http://a/g', $uri->resolve($base, '/g'), '/g'); | ||
$test->assertEquals('http://g', $uri->resolve($base, '//g'), '//g'); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
20 changes: 20 additions & 0 deletions
20
tests/Pyrus/JsonSchema/URI/uri_resolve2_queryfragment.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
JsonSchema: URI - resolve (2) with query and fragment | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/setup.php.inc'; | ||
$base = "http://a/b/c/d;p?q"; | ||
|
||
$test->assertEquals('http://a/b/c/d;p?y', $uri->resolve($base, '?y'), '?y'); | ||
$test->assertEquals('http://a/b/c/g?y', $uri->resolve($base, 'g?y'), 'g?y'); | ||
$test->assertEquals('http://a/b/c/d;p?q#s', $uri->resolve($base, '#s'), '#s'); | ||
$test->assertEquals('http://a/b/c/g#s', $uri->resolve($base, 'g#s'), 'g#s'); | ||
$test->assertEquals('http://a/b/c/g?y#s', $uri->resolve($base, 'g?y#s'), 'g?y#s'); | ||
$test->assertEquals('http://a/b/c/;x', $uri->resolve($base, ';x'), ';x'); | ||
$test->assertEquals('http://a/b/c/g;x', $uri->resolve($base, 'g;x'), 'g;x'); | ||
$test->assertEquals('http://a/b/c/g;x?y#s', $uri->resolve($base, 'g;x?y#s'), 'g;x?y#s'); | ||
$test->assertEquals('http://a/b/c/d;p?q', $uri->resolve($base, ''), '[empty]'); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
JsonSchema: URI - resolve (3) with dot segments | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/setup.php.inc'; | ||
$base = "http://a/b/c/d;p?q"; | ||
|
||
$test->assertEquals('http://a/b/c/', $uri->resolve($base, '.'), '.'); | ||
$test->assertEquals('http://a/b/c/', $uri->resolve($base, './'), './'); | ||
$test->assertEquals('http://a/b/', $uri->resolve($base, '..'), '..'); | ||
$test->assertEquals('http://a/b/', $uri->resolve($base, '../'), '../'); | ||
$test->assertEquals('http://a/b/g', $uri->resolve($base, '../g'), '../g'); | ||
$test->assertEquals('http://a/', $uri->resolve($base, '../..'), '../..'); | ||
$test->assertEquals('http://a/', $uri->resolve($base, '../../'), '../../'); | ||
$test->assertEquals('http://a/g', $uri->resolve($base, '../../g'), '../../g'); | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
JsonSchema: URI - resolve (4) with dot segments, abnormal examples | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/setup.php.inc'; | ||
$base = "http://a/b/c/d;p?q"; | ||
|
||
//abnormal examples from RFC 3986 | ||
$test->assertEquals('http://a/g', $uri->resolve($base, '../../../g'), '../../../g'); | ||
$test->assertEquals('http://a/g', $uri->resolve($base, '../../../../g'), '../../../../g'); | ||
|
||
$test->assertEquals('http://a/g', $uri->resolve($base, '/./g'), '/./g'); | ||
$test->assertEquals('http://a/g', $uri->resolve($base, '/../g'), '/../g'); | ||
$test->assertEquals('http://a/b/c/g.', $uri->resolve($base, 'g.'), 'g.'); | ||
$test->assertEquals('http://a/b/c/.g', $uri->resolve($base, '.g'), '.g'); | ||
$test->assertEquals('http://a/b/c/g..', $uri->resolve($base, 'g..'), 'g..'); | ||
$test->assertEquals('http://a/b/c/..g', $uri->resolve($base, '..g'), '..g'); | ||
|
||
$test->assertEquals('http://a/b/g', $uri->resolve($base, './../g'), './../g'); | ||
$test->assertEquals('http://a/b/c/g/', $uri->resolve($base, './g/.'), './g/.'); | ||
$test->assertEquals('http://a/b/c/h', $uri->resolve($base, 'g/../h'), 'g/../h'); | ||
$test->assertEquals('http://a/b/c/g;x=1/y', $uri->resolve($base, 'g;x=1/./y'), 'g;x=1/./y'); | ||
$test->assertEquals('http://a/b/c/y', $uri->resolve($base, 'g;x=1/../y'), 'g;x=1/../y'); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
16 changes: 16 additions & 0 deletions
16
tests/Pyrus/JsonSchema/URI/uri_resolve5_queryfragment_abnormal.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--TEST-- | ||
JsonSchema: URI - resolve (5) with abnormal query/fragment examples | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/setup.php.inc'; | ||
$base = "http://a/b/c/d;p?q"; | ||
|
||
//abnormal examples from RFC 3986 | ||
$test->assertEquals('http://a/b/c/g?y/./x', $uri->resolve($base, 'g?y/./x'), 'g?y/./x'); | ||
$test->assertEquals('http://a/b/c/g?y/../x', $uri->resolve($base, 'g?y/../x'), 'g?y/../x'); | ||
$test->assertEquals('http://a/b/c/g#y/./x', $uri->resolve($base, 'g#y/./x'), 'g#y/./x'); | ||
$test->assertEquals('http://a/b/c/g#y/../x', $uri->resolve($base, 'g#y/../x'), 'g#y/../x'); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--TEST-- | ||
JsonSchema: URI - resolve (6) tolerant | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/setup.php.inc'; | ||
$base = "http://a/b/c/d;p?q"; | ||
$options = new Pyrus\JsonSchema\URI\Options; | ||
$options->tolerant = true; | ||
|
||
//abnormal examples from RFC 3986 | ||
$test->assertEquals('http:g', $uri->resolve($base, 'http:g'), 'http:g, non-tolerant'); | ||
$test->assertEquals('http://a/b/c/g', $uri->resolve($base, 'http:g', $options), 'http:g, tolerant'); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |