summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/tests/strings/addcslashes_001.phptbin0 -> 1620 bytes
-rw-r--r--ext/standard/tests/strings/addcslashes_002.phpt33
-rw-r--r--ext/standard/tests/strings/addcslashes_003.phptbin0 -> 1618 bytes
-rw-r--r--ext/standard/tests/strings/addcslashes_004.phpt47
4 files changed, 80 insertions, 0 deletions
diff --git a/ext/standard/tests/strings/addcslashes_001.phpt b/ext/standard/tests/strings/addcslashes_001.phpt
new file mode 100644
index 0000000000..28a30aa52e
--- /dev/null
+++ b/ext/standard/tests/strings/addcslashes_001.phpt
Binary files differ
diff --git a/ext/standard/tests/strings/addcslashes_002.phpt b/ext/standard/tests/strings/addcslashes_002.phpt
new file mode 100644
index 0000000000..33baa846d8
--- /dev/null
+++ b/ext/standard/tests/strings/addcslashes_002.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test addcslashes() function (variation 2)
+--INI--
+precision=14
+--FILE--
+<?php
+
+$string = b"goodyear12345NULL\0truefalse\a\v\f\b\n\r\t";
+/* charlist "\0..\37" would escape all characters with ASCII code between 0 and 31 */
+echo "\n*** Testing addcslashes() with ASCII code between 0 and 31 ***\n";
+var_dump( addcslashes($string, b"\0..\37") );
+
+/* Checking OBJECTS type */
+echo "\n*** Testing addcslashes() with objects ***\n";
+class string1
+{
+ public function __toString() {
+ return "Object";
+ }
+}
+$obj = new string1;
+var_dump( addcslashes((binary)$obj, b"b") );
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+*** Testing addcslashes() with ASCII code between 0 and 31 ***
+string(44) "goodyear12345NULL\000truefalse\a\v\f\b\n\r\t"
+
+*** Testing addcslashes() with objects ***
+string(7) "O\bject"
+Done
diff --git a/ext/standard/tests/strings/addcslashes_003.phpt b/ext/standard/tests/strings/addcslashes_003.phpt
new file mode 100644
index 0000000000..10b1e99738
--- /dev/null
+++ b/ext/standard/tests/strings/addcslashes_003.phpt
Binary files differ
diff --git a/ext/standard/tests/strings/addcslashes_004.phpt b/ext/standard/tests/strings/addcslashes_004.phpt
new file mode 100644
index 0000000000..ba553a2688
--- /dev/null
+++ b/ext/standard/tests/strings/addcslashes_004.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test addcslashes() function (errors)
+--INI--
+precision=14
+--FILE--
+<?php
+
+echo "\n*** Testing error conditions ***\n";
+/* zero argument */
+var_dump( addcslashes() );
+
+/* unexpected arguments */
+var_dump( addcslashes(b"foo[]") );
+var_dump( addcslashes("foo", "foo") );
+var_dump( addcslashes(b'foo[]', b"o", b"foo") );
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: addcslashes() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: addcslashes() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+string(6) "\f\o\o"
+
+Warning: addcslashes() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing error conditions ***
+
+Warning: addcslashes() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: addcslashes() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: addcslashes() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d
+NULL
+
+Warning: addcslashes() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+Done