Skip to content
Browse files

added unit tests for testing literal, pct-encoded and utf8 string cop…

…ying
  • Loading branch information...
1 parent 3330717 commit c85c1491b50a702cab6abf9291bcfd0a97be020a @ioseb committed Nov 1, 2012
Showing with 69 additions and 0 deletions.
  1. +12 −0 tests/copyliterals1.phpt
  2. +12 −0 tests/copyliterals2.phpt
  3. +21 −0 tests/copyliterals3.phpt
  4. +12 −0 tests/copyliterals4.phpt
  5. +12 −0 tests/copyliterals5.phpt
View
12 tests/copyliterals1.phpt
@@ -0,0 +1,12 @@
+--TEST--
+uri_template() copy pct-encoded triplets
+--FILE--
+<?php
+
+$input = '%25x21%20%2F%20%25x23-24%20%2F%20%25x26%20%2F%20%25x28-3B%20%2F%20%25x3D%20%2F%20%25x3F-5B';
+$result = uri_template($input, array());
+
+var_dump($result);
+?>
+--EXPECT--
+string(90) "%25x21%20%2F%20%25x23-24%20%2F%20%25x26%20%2F%20%25x28-3B%20%2F%20%25x3D%20%2F%20%25x3F-5B"
View
12 tests/copyliterals2.phpt
@@ -0,0 +1,12 @@
+--TEST--
+uri_template() copy pct-encoded triplets and expand variables with utf8 strings
+--FILE--
+<?php
+
+$input = '%25x21%20%2F%20%25x23-{utf8str}-24%20%2F%20%25x26%20%2F%20%25x28-3B%20%2F%20%25x3D%20%2F%20%25x3F-{utf8str}-5B';
+$result = uri_template($input, array('utf8str' => 'სიმბოლო'));
+
+var_dump($result);
+?>
+--EXPECT--
+string(218) "%25x21%20%2F%20%25x23-%E1%83%A1%E1%83%98%E1%83%9B%E1%83%91%E1%83%9D%E1%83%9A%E1%83%9D-24%20%2F%20%25x26%20%2F%20%25x28-3B%20%2F%20%25x3D%20%2F%20%25x3F-%E1%83%A1%E1%83%98%E1%83%9B%E1%83%91%E1%83%9D%E1%83%9A%E1%83%9D-5B"
View
21 tests/copyliterals3.phpt
@@ -0,0 +1,21 @@
+--TEST--
+uri_template() copy literals, compare encoded literal chars and encoded variable value
+--FILE--
+<?php
+
+$utf8str = 'სიმბოლო';
+$template = '{utf8str}';
+$result = array(
+ uri_template($utf8str, array()),
+ uri_template($template, array('utf8str' => $utf8str))
+);
+
+var_dump($result);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(63) "%E1%83%A1%E1%83%98%E1%83%9B%E1%83%91%E1%83%9D%E1%83%9A%E1%83%9D"
+ [1]=>
+ string(63) "%E1%83%A1%E1%83%98%E1%83%9B%E1%83%91%E1%83%9D%E1%83%9A%E1%83%9D"
+}
View
12 tests/copyliterals4.phpt
@@ -0,0 +1,12 @@
+--TEST--
+uri_template() copy url - ignore ! char
+--FILE--
+<?php
+
+$input = 'http://foo.com/baz?bar=bam_!';
+$result = uri_template($input, array());
+
+var_dump($result);
+?>
+--EXPECT--
+string(28) "http://foo.com/baz?bar=bam_!"
View
12 tests/copyliterals5.phpt
@@ -0,0 +1,12 @@
+--TEST--
+uri_template() copy url - ignore %21 tripplet
+--FILE--
+<?php
+
+$input = 'http://foo.com/baz?bar=bam_%21';
+$result = uri_template($input, array());
+
+var_dump($result);
+?>
+--EXPECT--
+string(30) "http://foo.com/baz?bar=bam_%21"

0 comments on commit c85c149

Please sign in to comment.
Something went wrong with that request. Please try again.