]> granicus.if.org Git - php/commitdiff
- New tests
authorFelipe Pena <felipe@php.net>
Wed, 7 May 2008 14:10:03 +0000 (14:10 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 7 May 2008 14:10:03 +0000 (14:10 +0000)
Zend/tests/ns_064.phpt [new file with mode: 0644]
Zend/tests/objects_021.phpt [new file with mode: 0644]

diff --git a/Zend/tests/ns_064.phpt b/Zend/tests/ns_064.phpt
new file mode 100644 (file)
index 0000000..29e9e56
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Magic methods in overrided stdClass inside namespace
+--FILE--
+<?php
+
+namespace test;
+
+class foo {
+       public $e = array();
+       
+       public function __construct() {
+               $this->e[] = $this;
+       }
+       
+       public function __set($a, $b) {
+               var_dump($a, $b);
+       }
+       public function __get($a) {
+               var_dump($a);
+               return $this;
+       }
+}
+
+use test::foo as stdClass;
+
+$x = new stdClass;
+$x->a = 1;
+$x->b->c = 1;
+$x->d->e[0]->f = 2;
+
+?>
+--EXPECT--
+string(1) "a"
+int(1)
+string(1) "b"
+string(1) "c"
+int(1)
+string(1) "d"
+string(1) "f"
+int(2)
diff --git a/Zend/tests/objects_021.phpt b/Zend/tests/objects_021.phpt
new file mode 100644 (file)
index 0000000..70dcbfb
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Testing magic methods __set, __get and __call in cascade
+--FILE--
+<?php
+
+class test {
+       static public $i = 0;
+       
+       public function __construct() {
+               self::$i++;
+       }
+       
+       public function __set($a, $b) {
+               return x();
+       }
+       
+       public function __get($a) {
+               return x();
+       }
+       
+       public function __call($a, $b) {
+               return x();
+       }
+}
+
+function x() {
+       return new test;
+}
+
+x()
+       ->a
+               ->b()
+                       ->c     = 1;
+
+var_dump(test::$i);
+
+?>
+--EXPECT--
+int(4)