]> granicus.if.org Git - php/commitdiff
- New tests
authorFelipe Pena <felipe@php.net>
Fri, 18 Apr 2008 13:54:46 +0000 (13:54 +0000)
committerFelipe Pena <felipe@php.net>
Fri, 18 Apr 2008 13:54:46 +0000 (13:54 +0000)
Zend/tests/024.phpt [new file with mode: 0644]
Zend/tests/025.phpt [new file with mode: 0644]
Zend/tests/026.phpt [new file with mode: 0644]
Zend/tests/027.phpt [new file with mode: 0644]
Zend/tests/028.phpt [new file with mode: 0644]
Zend/tests/029.phpt [new file with mode: 0644]
Zend/tests/030.phpt [new file with mode: 0644]

diff --git a/Zend/tests/024.phpt b/Zend/tests/024.phpt
new file mode 100644 (file)
index 0000000..6fe1020
--- /dev/null
@@ -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 (file)
index 0000000..24e5520
--- /dev/null
@@ -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 (file)
index 0000000..784b12c
--- /dev/null
@@ -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 (file)
index 0000000..a862d68
--- /dev/null
@@ -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 (file)
index 0000000..2c58a87
--- /dev/null
@@ -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 (file)
index 0000000..469dd08
--- /dev/null
@@ -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 (file)
index 0000000..f6af9c0
--- /dev/null
@@ -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