summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-04-18 14:05:47 +0000
committerFelipe Pena <felipe@php.net>2008-04-18 14:05:47 +0000
commit3d2a5940a2d1f087623b77a3182fa2cfbd46666c (patch)
tree76f30c12a3961b393fee73576cbd0ed7d20464bc /Zend
parentdfe7affab5bad2daad8da756aab781f4e457b116 (diff)
downloadphp-git-3d2a5940a2d1f087623b77a3182fa2cfbd46666c.tar.gz
- New tests
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/024.phpt51
-rw-r--r--Zend/tests/025.phpt32
-rw-r--r--Zend/tests/026.phpt25
-rw-r--r--Zend/tests/027.phpt22
-rw-r--r--Zend/tests/028.phpt23
-rw-r--r--Zend/tests/029.phpt85
-rw-r--r--Zend/tests/030.phpt104
7 files changed, 342 insertions, 0 deletions
diff --git a/Zend/tests/024.phpt b/Zend/tests/024.phpt
new file mode 100644
index 0000000000..6fe10201f5
--- /dev/null
+++ b/Zend/tests/024.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Testing operations with undefined variable
+--FILE--
+<?php
+
+var_dump($a[1]);
+var_dump($a[$c]);
+var_dump($a + 1);
+var_dump($a + $b);
+var_dump($a++);
+var_dump(++$b);
+var_dump($a->$b);
+var_dump($a->$b);
+var_dump($a->$b->$c[1]);
+
+?>
+--EXPECTF--
+Notice: Undefined variable: a in %s on line %d
+NULL
+
+Notice: Undefined variable: c in %s on line %d
+
+Notice: Undefined variable: a in %s on line %d
+NULL
+
+Notice: Undefined variable: a in %s on line %d
+int(1)
+
+Notice: Undefined variable: b in %s on line %d
+
+Notice: Undefined variable: a in %s on line %d
+int(0)
+
+Notice: Undefined variable: a in %s on line %d
+NULL
+
+Notice: Undefined variable: b in %s on line %d
+int(1)
+
+Notice: Trying to get property of non-object in %s on line %d
+NULL
+
+Notice: Trying to get property of non-object in %s on line %d
+NULL
+
+Notice: Undefined variable: c in %s on line %d
+
+Notice: Trying to get property of non-object in %s on line %d
+
+Notice: Trying to get property of non-object in %s on line %d
+NULL
diff --git a/Zend/tests/025.phpt b/Zend/tests/025.phpt
new file mode 100644
index 0000000000..24e5520ee1
--- /dev/null
+++ b/Zend/tests/025.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Testing dynamic calls
+--FILE--
+<?php
+
+class foo {
+ static public function a() {
+ print "ok\n";
+ }
+}
+
+$a = 'a';
+$b = 'a';
+
+$class = 'foo';
+
+foo::a();
+foo::$a();
+foo::$$b();
+
+$class::a();
+$class::$a();
+$class::$$b();
+
+?>
+--EXPECT--
+ok
+ok
+ok
+ok
+ok
+ok
diff --git a/Zend/tests/026.phpt b/Zend/tests/026.phpt
new file mode 100644
index 0000000000..784b12c69b
--- /dev/null
+++ b/Zend/tests/026.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Trying assign value to property when an object is not returned in a function
+--FILE--
+<?php
+
+class foo {
+ public function a() {
+ }
+}
+
+$test = new foo;
+
+$test->a()->a;
+print "ok\n";
+
+$test->a()->a = 1;
+print "ok\n";
+
+?>
+--EXPECTF--
+Notice: Trying to get property of non-object in %s on line %d
+ok
+
+Strict Standards: Creating default object from empty value in %s on line %d
+ok
diff --git a/Zend/tests/027.phpt b/Zend/tests/027.phpt
new file mode 100644
index 0000000000..a862d689e1
--- /dev/null
+++ b/Zend/tests/027.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Testing dynamic calls using variable variables with curly syntax
+--FILE--
+<?php
+
+$a = 'b';
+$b = 'c';
+$c = 'strtoupper';
+
+var_dump(${${$a}}('foo') == 'FOO');
+
+$a = 'b';
+$b = 'c';
+$c = 'strtoupper';
+$strtoupper = 'strtolower';
+
+var_dump(${${++$a}}('FOO') == 'foo');
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/Zend/tests/028.phpt b/Zend/tests/028.phpt
new file mode 100644
index 0000000000..2c58a87b32
--- /dev/null
+++ b/Zend/tests/028.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Testing function call through of array item
+--FILE--
+<?php
+
+$arr = array('strtoupper', 'strtolower');
+
+$k = 0;
+
+var_dump($arr[0]('foo') == 'FOO');
+var_dump($arr[$k]('foo') == 'FOO');
+var_dump($arr[++$k]('FOO') == 'foo');
+var_dump($arr[++$k]('FOO') == 'foo');
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+
+Notice: Undefined offset: 2 in %s on line %d
+
+Fatal error: Function name must be a string in %s on line %d
diff --git a/Zend/tests/029.phpt b/Zend/tests/029.phpt
new file mode 100644
index 0000000000..469dd081bb
--- /dev/null
+++ b/Zend/tests/029.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Testing assign to property of an object in an array
+--FILE--
+<?php
+
+$arr = array(new stdClass);
+
+$arr[0]->a = clone $arr[0];
+var_dump($arr);
+
+$arr[0]->b = new $arr[0];
+var_dump($arr);
+
+$arr[0]->c = $arr[0]->a;
+var_dump($arr);
+
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ object(stdClass)#1 (1) {
+ ["a"]=>
+ object(stdClass)#2 (0) {
+ }
+ }
+}
+array(1) {
+ [0]=>
+ object(stdClass)#1 (2) {
+ ["a"]=>
+ object(stdClass)#2 (0) {
+ }
+ ["b"]=>
+ object(stdClass)#3 (0) {
+ }
+ }
+}
+array(1) {
+ [0]=>
+ object(stdClass)#1 (3) {
+ ["a"]=>
+ object(stdClass)#2 (0) {
+ }
+ ["b"]=>
+ object(stdClass)#3 (0) {
+ }
+ ["c"]=>
+ object(stdClass)#2 (0) {
+ }
+ }
+}
+--UEXPECT--
+array(1) {
+ [0]=>
+ object(stdClass)#1 (1) {
+ [u"a"]=>
+ object(stdClass)#2 (0) {
+ }
+ }
+}
+array(1) {
+ [0]=>
+ object(stdClass)#1 (2) {
+ [u"a"]=>
+ object(stdClass)#2 (0) {
+ }
+ [u"b"]=>
+ object(stdClass)#3 (0) {
+ }
+ }
+}
+array(1) {
+ [0]=>
+ object(stdClass)#1 (3) {
+ [u"a"]=>
+ object(stdClass)#2 (0) {
+ }
+ [u"b"]=>
+ object(stdClass)#3 (0) {
+ }
+ [u"c"]=>
+ object(stdClass)#2 (0) {
+ }
+ }
+}
diff --git a/Zend/tests/030.phpt b/Zend/tests/030.phpt
new file mode 100644
index 0000000000..f6af9c0584
--- /dev/null
+++ b/Zend/tests/030.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Overriding $this in catch and checking the object properties later.
+--FILE--
+<?php
+
+class foo {
+ public $test = 0;
+ private $test_2 = 1;
+ protected $test_3 = 2;
+
+ public function bar() {
+ try {
+ throw new Exception('foo');
+ } catch (Exception $this) {
+ var_dump($this);
+ }
+
+ $this->baz();
+ }
+
+ public function baz() {
+ foreach ($this as $k => $v) {
+ printf("'%s' => '%s'\n", $k, $v);
+ }
+ print "ok\n";
+ }
+}
+
+$test = new foo;
+$test->bar();
+
+?>
+--EXPECTF--
+object(Exception)#2 (6) {
+ ["message":protected]=>
+ string(3) "foo"
+ ["string":"Exception":private]=>
+ string(0) ""
+ ["code":protected]=>
+ int(0)
+ ["file":protected]=>
+ string(%d) "%s"
+ ["line":protected]=>
+ int(%d)
+ ["trace":"Exception":private]=>
+ array(1) {
+ [0]=>
+ array(6) {
+ ["file"]=>
+ string(%d) "%s"
+ ["line"]=>
+ int(%d)
+ ["function"]=>
+ string(3) "bar"
+ ["class"]=>
+ string(3) "foo"
+ ["type"]=>
+ string(2) "->"
+ ["args"]=>
+ array(0) {
+ }
+ }
+ }
+}
+'test' => '0'
+'test_2' => '1'
+'test_3' => '2'
+ok
+--UEXPECTF--
+object(Exception)#2 (6) {
+ ["message":protected]=>
+ string(3) "foo"
+ ["string":"Exception":private]=>
+ string(0) ""
+ ["code":protected]=>
+ int(0)
+ ["file":protected]=>
+ string(32) "%s"
+ ["line":protected]=>
+ int(%d)
+ ["trace":"Exception":private]=>
+ array(1) {
+ [0]=>
+ array(6) {
+ ["file"]=>
+ string(32) "%s"
+ ["line"]=>
+ int(%d)
+ ["function"]=>
+ string(3) "bar"
+ ["class"]=>
+ string(3) "foo"
+ ["type"]=>
+ string(2) "->"
+ ["args"]=>
+ array(0) {
+ }
+ }
+ }
+}
+'test' => '0'
+'test_2' => '1'
+'test_3' => '2'
+ok