ant             Mon Nov 17 12:50:18 2008 UTC

  Modified files:              
    /php-src/ext/reflection/tests       reflectionObject_export_basic3.phpt 
                                        reflectionObject_export_basic1.phpt 
                                        reflectionClass_export_basic1.phpt 
                                        reflectionObject___toString_basic2.phpt 
                                        reflectionObject_export_basic2.phpt 
                                        reflectionObject___toString_basic1.phpt 
                                        reflectionClass_export_basic2.phpt 
                                        
reflectionProperty_constructor_variation1.phpt 
  Log:
  Commit tests for ext/reflection
  
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionObject_export_basic3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionObject_export_basic3.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionObject_export_basic3.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionObject_export_basic3.phpt    Mon Nov 
17 12:50:18 2008
@@ -0,0 +1,38 @@
+--TEST--
+ReflectionObject::export() - ensure dynamic property with same name as 
inherited private property is shown. 
+--FILE--
+<?php
+class C {
+       private $p = 1;
+}
+
+class D extends C{
+}
+
+$Obj = new D;
+$Obj->p = 'value';
+ReflectionObject::export($Obj)
+?>
+--EXPECTF--
+Object of class [ <user> class D extends C ] {
+  @@ %s 6-7
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Dynamic properties [0] {
+  }
+
+  - Methods [0] {
+  }
+}
+
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionObject_export_basic1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionObject_export_basic1.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionObject_export_basic1.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionObject_export_basic1.phpt    Mon Nov 
17 12:50:18 2008
@@ -0,0 +1,36 @@
+--TEST--
+ReflectionObject::export() : very basic test with no dynamic properties
+--FILE--
+<?php
+
+class Foo  {
+       public $bar = 1;
+}
+$f = new foo;
+
+ReflectionObject::export($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+  @@ %s 3-5
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [1] {
+    Property [ <default> public $bar ]
+  }
+
+  - Dynamic properties [0] {
+  }
+
+  - Methods [0] {
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_export_basic1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_export_basic1.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_export_basic1.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionClass_export_basic1.phpt     Mon Nov 
17 12:50:18 2008
@@ -0,0 +1,62 @@
+--TEST--
+ReflectionClass::export() - various parameters
+--FILE--
+<?php
+Class A { 
+       public function privf(Exception $a) {}
+       public function pubf(A $a,
+                                                $b,
+                                                C $c = null,
+                                                $d = K,
+                                                $e = "15 chars long -",
+                                                $f = null,
+                                                $g = false,
+                                                array $h = null) {}
+}
+
+Class C extends A { }
+
+define('K', "16 chars long --");
+ReflectionClass::export("C");
+?>
+--EXPECTF--
+Class [ <user> class C extends A ] {
+  @@ %s 14-14
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [2] {
+    Method [ <user, inherits A> public method privf ] {
+      @@ %s 3 - 3
+
+      - Parameters [1] {
+        Parameter #0 [ <required> Exception $a ]
+      }
+    }
+
+    Method [ <user, inherits A> public method pubf ] {
+      @@ %s 4 - 11
+
+      - Parameters [8] {
+        Parameter #0 [ <required> A $a ]
+        Parameter #1 [ <required> $b ]
+        Parameter #2 [ <optional> C or NULL $c = NULL ]
+        Parameter #3 [ <optional> $d = '16 chars long -...' ]
+        Parameter #4 [ <optional> $e = '15 chars long -' ]
+        Parameter #5 [ <optional> $f = NULL ]
+        Parameter #6 [ <optional> $g = false ]
+        Parameter #7 [ <optional> array or NULL $h = NULL ]
+      }
+    }
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionObject___toString_basic2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionObject___toString_basic2.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionObject___toString_basic2.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionObject___toString_basic2.phpt        
Mon Nov 17 12:50:18 2008
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionObject::__toString() : very basic test with dynamic properties
+--FILE--
+<?php
+
+class Foo  {
+       public $bar = 1;
+}
+$f = new foo;
+$f->dynProp = 'hello';
+$f->dynProp2 = 'hello again';
+echo new ReflectionObject($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+  @@ %s 3-5
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [1] {
+    Property [ <default> public $bar ]
+  }
+
+  - Dynamic properties [2] {
+    Property [ <dynamic> public $dynProp ]
+    Property [ <dynamic> public $dynProp2 ]
+  }
+
+  - Methods [0] {
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionObject_export_basic2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionObject_export_basic2.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionObject_export_basic2.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionObject_export_basic2.phpt    Mon Nov 
17 12:50:18 2008
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionObject::export() : very basic test with dynamic properties
+--FILE--
+<?php
+
+class Foo  {
+       public $bar = 1;
+}
+$f = new foo;
+$f->dynProp = 'hello';
+$f->dynProp2 = 'hello again';
+ReflectionObject::export($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+  @@ %s 3-5
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [1] {
+    Property [ <default> public $bar ]
+  }
+
+  - Dynamic properties [2] {
+    Property [ <dynamic> public $dynProp ]
+    Property [ <dynamic> public $dynProp2 ]
+  }
+
+  - Methods [0] {
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionObject___toString_basic1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionObject___toString_basic1.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionObject___toString_basic1.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionObject___toString_basic1.phpt        
Mon Nov 17 12:50:18 2008
@@ -0,0 +1,37 @@
+--TEST--
+ReflectionObject::__toString() : very basic test with no dynamic properties
+--FILE--
+<?php
+
+class Foo  {
+       public $bar = 1;
+}
+$f = new foo;
+
+echo new ReflectionObject($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+  @@ %s 3-5
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [1] {
+    Property [ <default> public $bar ]
+  }
+
+  - Dynamic properties [0] {
+  }
+
+  - Methods [0] {
+  }
+}
+
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_export_basic2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_export_basic2.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_export_basic2.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionClass_export_basic2.phpt     Mon Nov 
17 12:50:18 2008
@@ -0,0 +1,54 @@
+--TEST--
+ReflectionClass::export() - ensure inherited private props are hidden.
+--FILE--
+<?php
+Class c {
+       private $a;
+       static private $b;
+}
+
+class d extends c {}
+
+ReflectionClass::export("c");
+ReflectionClass::export("d");
+?>
+--EXPECTF--
+Class [ <user> class c ] {
+  @@ %s 2-5
+
+  - Constants [0] {
+  }
+
+  - Static properties [1] {
+    Property [ private static $b ]
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [1] {
+    Property [ <default> private $a ]
+  }
+
+  - Methods [0] {
+  }
+}
+
+Class [ <user> class d extends c ] {
+  @@ %s 7-7
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [0] {
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_constructor_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/reflection/tests/reflectionProperty_constructor_variation1.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionProperty_constructor_variation1.phpt:1.2
--- /dev/null   Mon Nov 17 12:50:18 2008
+++ php-src/ext/reflection/tests/reflectionProperty_constructor_variation1.phpt 
Mon Nov 17 12:50:18 2008
@@ -0,0 +1,58 @@
+--TEST--
+ReflectionProperty::__construct(): ensure inherited private props can't be 
accessed through ReflectionProperty.
+--FILE--
+<?php
+
+class C {
+       private $p = 1;
+       
+       static function testFromC() {
+               try {
+                 $rp = new ReflectionProperty("D", "p");
+                 var_dump($rp);
+               } catch (Exception $e) {
+                       echo $e->getMessage();
+               }               
+       }
+}
+
+class D extends C{
+       static function testFromD() {
+               try {
+                 $rp = new ReflectionProperty("D", "p");
+                 var_dump($rp);
+               } catch (Exception $e) {
+                       echo $e->getMessage();
+               }               
+       }
+}
+
+echo "--> Reflect inherited private from global scope:\n";
+try {
+  $rp = new ReflectionProperty("D", "p");
+  var_dump($rp);
+} catch (Exception $e) {
+       echo $e->getMessage();
+}
+
+echo "\n\n--> Reflect inherited private from declaring scope:\n";
+C::testFromC();
+
+echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n";
+D::testFromC();
+
+echo "\n\n--> Reflect inherited private from subclass:\n";
+D::testFromD();
+?>
+--EXPECTF--
+--> Reflect inherited private from global scope:
+Property D::$p does not exist
+
+--> Reflect inherited private from declaring scope:
+Property D::$p does not exist
+
+--> Reflect inherited private from declaring scope via subclass:
+Property D::$p does not exist
+
+--> Reflect inherited private from subclass:
+Property D::$p does not exist
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to