]> granicus.if.org Git - php/commitdiff
Add test for foreach visibility
authorMarcus Boerger <helly@php.net>
Fri, 19 Dec 2003 10:16:08 +0000 (10:16 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 19 Dec 2003 10:16:08 +0000 (10:16 +0000)
tests/classes/visibility_005.phpt [new file with mode: 0755]

diff --git a/tests/classes/visibility_005.phpt b/tests/classes/visibility_005.phpt
new file mode 100755 (executable)
index 0000000..1b15fb5
--- /dev/null
@@ -0,0 +1,58 @@
+--TEST--
+ZE2 foreach and property visibility
+--FILE--
+<?php
+
+class base
+{
+       public $a=1;
+       protected $b=2;
+       private $c=3;
+
+       function f()
+       {
+               foreach($this as $k=>$v) {
+                       echo "$k=>$v\n";
+               }
+       }
+}
+
+class derived extends base
+{
+}
+
+$o = new base;
+$o->d = 4;
+echo "===base::function===\n";
+$o->f();
+echo "===base,foreach===\n";
+foreach($o as $k=>$v) {
+       echo "$k=>$v\n";
+}
+
+$o = new derived;
+$o->d = 4;
+echo "===derived::function===\n";
+$o->f();
+echo "===derived,foreach===\n";
+foreach($o as $k=>$v) {
+       echo "$k=>$v\n";
+}
+
+?>
+--EXPECT--
+===base::function===
+a=>1
+b=>2
+c=>3
+d=>4
+===base,foreach===
+a=>1
+d=>4
+===derived::function===
+a=>1
+b=>2
+d=>4
+===derived,foreach===
+a=>1
+d=>4