From 6ce41aa113654d507937e31a18656cbafebbd1ce Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Thu, 28 Jul 2011 13:38:49 -0500 Subject: [PATCH] new test for serialize, fix urlencoding of stuff that needs urlencoding --- src/Pyrus/JsonSchema/URI.php | 2 +- tests/Pyrus/JsonSchema/URI/uri_serialize.phpt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/Pyrus/JsonSchema/URI/uri_serialize.phpt diff --git a/src/Pyrus/JsonSchema/URI.php b/src/Pyrus/JsonSchema/URI.php index 0e2af52..22cc5a6 100644 --- a/src/Pyrus/JsonSchema/URI.php +++ b/src/Pyrus/JsonSchema/URI.php @@ -225,7 +225,7 @@ function utfCharToNumber($char) // from PHP manual comments on ord() function pctEncChar($matches) { $chr = $matches[0]; - $c = $this->utfCharToNumber(dechex($chr[0])); + $c = $this->utfCharToNumber($chr); if ($c < 128) { return "%" . strtoupper(dechex($c)); diff --git a/tests/Pyrus/JsonSchema/URI/uri_serialize.phpt b/tests/Pyrus/JsonSchema/URI/uri_serialize.phpt new file mode 100644 index 0000000..a055034 --- /dev/null +++ b/tests/Pyrus/JsonSchema/URI/uri_serialize.phpt @@ -0,0 +1,18 @@ +--TEST-- +JsonSchema: URI - serialize +--FILE-- +scheme = '%http'; +$components->userinfo = 'babyface:boo'; +$components->host = 'far.example.com'; +$components->port = '8080'; +$components->path = '/hi.my.thingy/./there'; +$components->query = 'my=1&there=there'; +$components->fragment = '#'; +$test->assertEquals('http://babyface:boo@far.example.com/hi.my.thingy/there?my=1&there=there#%23', $uri->serialize($components), 'serialize'); +?> +===DONE=== +--EXPECT-- +===DONE=== \ No newline at end of file