add tests
authorMichael Wallner <mike@php.net>
Thu, 16 Jan 2014 21:11:10 +0000 (22:11 +0100)
committerMichael Wallner <mike@php.net>
Thu, 16 Jan 2014 21:11:10 +0000 (22:11 +0100)
tests/params003.phpt [new file with mode: 0644]
tests/params004.phpt [new file with mode: 0644]

diff --git a/tests/params003.phpt b/tests/params003.phpt
new file mode 100644 (file)
index 0000000..c9cec72
--- /dev/null
@@ -0,0 +1,79 @@
+--TEST--
+header params rfc5987
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$p = new http\Params("attachment; filename*=IsO-8859-1''d%f6ner.pdf");
+var_dump($p->params, (string) $p);
+$p = new http\Params("bar; title*=iso-8859-1'en'%A3%20rates");
+var_dump($p->params, (string) $p);
+$p = new http\Params("bar; title*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates");
+var_dump($p->params, (string) $p);
+
+?>
+===DONE===
+--EXPECT--
+Test
+array(1) {
+  ["attachment"]=>
+  array(2) {
+    ["value"]=>
+    bool(true)
+    ["arguments"]=>
+    array(1) {
+      ["*rfc5987*"]=>
+      array(1) {
+        ["filename"]=>
+        array(1) {
+          [""]=>
+          string(10) "döner.pdf"
+        }
+      }
+    }
+  }
+}
+string(42) "attachment;filename*=utf-8''d%C3%B6ner.pdf"
+array(1) {
+  ["bar"]=>
+  array(2) {
+    ["value"]=>
+    bool(true)
+    ["arguments"]=>
+    array(1) {
+      ["*rfc5987*"]=>
+      array(1) {
+        ["title"]=>
+        array(1) {
+          ["en"]=>
+          string(8) "£ rates"
+        }
+      }
+    }
+  }
+}
+string(34) "bar;title*=utf-8'en'%C2%A3%20rates"
+array(1) {
+  ["bar"]=>
+  array(2) {
+    ["value"]=>
+    bool(true)
+    ["arguments"]=>
+    array(1) {
+      ["*rfc5987*"]=>
+      array(1) {
+        ["title"]=>
+        array(1) {
+          [""]=>
+          string(16) "£ and € rates"
+        }
+      }
+    }
+  }
+}
+string(50) "bar;title*=utf-8''%C2%A3%20and%20%E2%82%AC%20rates"
+===DONE===
\ No newline at end of file
diff --git a/tests/params004.phpt b/tests/params004.phpt
new file mode 100644 (file)
index 0000000..680c055
--- /dev/null
@@ -0,0 +1,68 @@
+--TEST--
+header params rfc5987
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+$u = urlencode("ü");
+$s = urlencode("ß");
+$t = "p1*=utf-8''s$u$s,p2*=utf-8''hei$s;a1*=utf-8''a$s;a2*=utf-8''e$s;a3=no,p3=not";
+$p = new http\Params($t);
+var_dump($p->params);
+var_dump((string)$p === $t);
+?>
+===DONE===
+--EXPECT--
+Test
+array(3) {
+  ["p1"]=>
+  array(2) {
+    ["*rfc5987*"]=>
+    array(1) {
+      [""]=>
+      string(5) "süß"
+    }
+    ["arguments"]=>
+    array(0) {
+    }
+  }
+  ["p2"]=>
+  array(2) {
+    ["*rfc5987*"]=>
+    array(1) {
+      [""]=>
+      string(5) "heiß"
+    }
+    ["arguments"]=>
+    array(2) {
+      ["*rfc5987*"]=>
+      array(2) {
+        ["a1"]=>
+        array(1) {
+          [""]=>
+          string(3) "aß"
+        }
+        ["a2"]=>
+        array(1) {
+          [""]=>
+          string(3) "eß"
+        }
+      }
+      ["a3"]=>
+      string(2) "no"
+    }
+  }
+  ["p3"]=>
+  array(2) {
+    ["value"]=>
+    string(3) "not"
+    ["arguments"]=>
+    array(0) {
+    }
+  }
+}
+bool(true)
+===DONE===