summaryrefslogtreecommitdiff
path: root/tests/strings
diff options
context:
space:
mode:
authorFerenc Kovacs <tyrael@php.net>2011-11-26 18:41:45 +0000
committerFerenc Kovacs <tyrael@php.net>2011-11-26 18:41:45 +0000
commit6f8518fbf57385185318ba3777b2e9ccb9e4b735 (patch)
tree0e8856f8d161d62576b8d637954fd42e8d05f41b /tests/strings
parent350325d42a046493913f3458ebb4305a732560d0 (diff)
downloadphp-git-6f8518fbf57385185318ba3777b2e9ccb9e4b735.tar.gz
adding some tests for string offsets
Diffstat (limited to 'tests/strings')
-rw-r--r--tests/strings/offsets_chaining_1.phpt11
-rw-r--r--tests/strings/offsets_chaining_2.phpt11
-rw-r--r--tests/strings/offsets_chaining_3.phpt11
-rw-r--r--tests/strings/offsets_chaining_4.phpt11
-rw-r--r--tests/strings/offsets_chaining_5.phpt23
-rw-r--r--tests/strings/offsets_general.phpt33
6 files changed, 100 insertions, 0 deletions
diff --git a/tests/strings/offsets_chaining_1.phpt b/tests/strings/offsets_chaining_1.phpt
new file mode 100644
index 0000000000..3aae90747c
--- /dev/null
+++ b/tests/strings/offsets_chaining_1.phpt
@@ -0,0 +1,11 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump($string[0][0][0][0]);
+?>
+--EXPECTF--
+Fatal error: Cannot use string offset as an array in %s on line %d
diff --git a/tests/strings/offsets_chaining_2.phpt b/tests/strings/offsets_chaining_2.phpt
new file mode 100644
index 0000000000..7a567cd125
--- /dev/null
+++ b/tests/strings/offsets_chaining_2.phpt
@@ -0,0 +1,11 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump($string{0}{0}[0][0]);
+?>
+--EXPECTF--
+Fatal error: Cannot use string offset as an array in %s on line %d
diff --git a/tests/strings/offsets_chaining_3.phpt b/tests/strings/offsets_chaining_3.phpt
new file mode 100644
index 0000000000..a5d1233a4c
--- /dev/null
+++ b/tests/strings/offsets_chaining_3.phpt
@@ -0,0 +1,11 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump(isset($string[0][0][0][0]));
+?>
+--EXPECTF--
+Fatal error: Cannot use string offset as an array in %s on line %d
diff --git a/tests/strings/offsets_chaining_4.phpt b/tests/strings/offsets_chaining_4.phpt
new file mode 100644
index 0000000000..8049f66a09
--- /dev/null
+++ b/tests/strings/offsets_chaining_4.phpt
@@ -0,0 +1,11 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump(isset($string{0}{0}[0][0]));
+?>
+--EXPECTF--
+Fatal error: Cannot use string offset as an array in %s on line %d
diff --git a/tests/strings/offsets_chaining_5.phpt b/tests/strings/offsets_chaining_5.phpt
new file mode 100644
index 0000000000..bb811326f8
--- /dev/null
+++ b/tests/strings/offsets_chaining_5.phpt
@@ -0,0 +1,23 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$array = array('expected_array' => "foobar");
+var_dump(isset($array['expected_array']));
+var_dump($array['expected_array']);
+var_dump(isset($array['expected_array']['foo']));
+var_dump($array['expected_array']['foo']);
+var_dump(isset($array['expected_array']['foo']['bar']));
+var_dump($array['expected_array']['foo']['bar']);
+?>
+--EXPECTF--
+bool(true)
+string(6) "foobar"
+bool(true)
+string(1) "f"
+bool(false)
+
+Fatal error: Cannot use string offset as an array in %s on line %d
+
diff --git a/tests/strings/offsets_general.phpt b/tests/strings/offsets_general.phpt
new file mode 100644
index 0000000000..effe9dd1d2
--- /dev/null
+++ b/tests/strings/offsets_general.phpt
@@ -0,0 +1,33 @@
+--TEST--
+testing the behavior of string offsets
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump($string[0]);
+var_dump($string[1]);
+var_dump(isset($string[0]));
+var_dump(isset($string[0][0]));
+var_dump($string["foo"]);
+var_dump(isset($string["foo"]["bar"]));
+var_dump($string{0});
+var_dump($string{1});
+var_dump(isset($string{0}));
+var_dump(isset($string{0}{0}));
+var_dump($string{"foo"});
+var_dump(isset($string{"foo"}{"bar"}));
+?>
+--EXPECT--
+string(1) "f"
+string(1) "o"
+bool(true)
+bool(false)
+string(1) "f"
+bool(false)
+string(1) "f"
+string(1) "o"
+bool(true)
+bool(false)
+string(1) "f"
+bool(false)