robinf          Thu May 22 21:54:01 2008 UTC

  Modified files:              
    /php-src/ext/reflection/tests       
                                        reflectionClass_isInterface_basic.phpt 
                                        reflectionClass_hasMethod_basic.phpt 
                                        
reflectionClass_isIterateable_basic.phpt 
                                        reflectionClass_getParentClass.phpt 
                                        reflectionClass_hasProperty_basic.phpt 
                                        reflectionClass_getModifiers_basic.phpt 
                                        
reflectionClass_isIterateable_variation1.phpt 
                                        reflectionClass_hasConstant_basic.phpt 
  Log:
  Basic ReflectionClass tests (from Dutch TestFest)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_isInterface_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_isInterface_basic.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_isInterface_basic.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_isInterface_basic.phpt Thu May 
22 21:54:01 2008
@@ -0,0 +1,27 @@
+--TEST--
+ReflectionClass::isInterface() method
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <[EMAIL PROTECTED]>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+
+interface TestInterface {}
+class TestClass {}
+interface DerivedInterface extends TestInterface {}
+
+$reflectionClass = new ReflectionClass('TestInterface');
+$reflectionClass2 = new ReflectionClass('TestClass');
+$reflectionClass3 = new ReflectionClass('DerivedInterface');
+
+var_dump($reflectionClass->isInterface());
+var_dump($reflectionClass2->isInterface());
+var_dump($reflectionClass3->isInterface());
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_hasMethod_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_hasMethod_basic.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_hasMethod_basic.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_hasMethod_basic.phpt   Thu May 
22 21:54:01 2008
@@ -0,0 +1,57 @@
+--TEST--
+ReflectionClass::hasMethod()
+--CREDIT--
+Marc Veldman <[EMAIL PROTECTED]>
+#testfest roosendaal on 2008-05-10
+--FILE-- 
+<?php
+//New instance of class C - defined below
+$rc = new ReflectionClass("C");
+
+//Check if C has public method publicFoo
+var_dump($rc->hasMethod('publicFoo'));
+
+//Check if C has protected method protectedFoo
+var_dump($rc->hasMethod('protectedFoo'));
+
+//Check if C has private method privateFoo
+var_dump($rc->hasMethod('privateFoo'));
+
+//Check if C has static method staticFoo
+var_dump($rc->hasMethod('staticFoo'));
+
+//C should not have method bar
+var_dump($rc->hasMethod('bar'));
+
+//Method names are case insensitive
+var_dump($rc->hasMethod('PUBLICfOO'));
+
+Class C {
+  public function publicFoo()
+  {
+    return true;
+  }
+
+  protected function protectedFoo()
+  {
+    return true;
+  }
+
+  private function privateFoo()
+  {
+    return true;
+  }
+
+  static function staticFoo()
+  {
+    return true;
+  }
+}
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_isIterateable_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_isIterateable_basic.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_isIterateable_basic.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_isIterateable_basic.phpt       
Thu May 22 21:54:01 2008
@@ -0,0 +1,36 @@
+--TEST--
+ReflectionClass::isIterateable() basic
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <[EMAIL PROTECTED]>, Marc Veldman <[EMAIL PROTECTED]>
+--FILE--
+<?php
+
+class IteratorClass implements Iterator {
+       public function __construct() { }
+       public function key() {}
+       public function current() {}
+       function next() {}
+       function valid() {}
+       function rewind() {}
+}
+class DerivedClass extends IteratorClass {}
+class NonIterator {}
+
+function dump_iterateable($class) {
+       $reflection = new ReflectionClass($class);
+       var_dump($reflection->isIterateable());
+}
+
+$classes = array("ArrayObject", "IteratorClass", "DerivedClass", 
"NonIterator");
+foreach ($classes as $class) {
+       echo "Is $class iterateable? ";
+       dump_iterateable($class);
+}
+?>
+--EXPECT--
+Is ArrayObject iterateable? bool(true)
+Is IteratorClass iterateable? bool(true)
+Is DerivedClass iterateable? bool(true)
+Is NonIterator iterateable? bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_getParentClass.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_getParentClass.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_getParentClass.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_getParentClass.phpt    Thu May 
22 21:54:01 2008
@@ -0,0 +1,24 @@
+--TEST--
+ReflectionClass::getParentClass()
+--CREDITS--
+Michelangelo van Dam <[EMAIL PROTECTED]>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+class Foo {}
+
+class Bar extends Foo {}
+
+$rc1 = new ReflectionClass("Bar");
+var_dump($rc1->getParentClass());
+?>
+--EXPECTF--
+object(ReflectionClass)#%d (1) {
+  ["name"]=>
+  string(3) "Foo"
+}
+--UEXPECTF--
+object(ReflectionClass)#%d (1) {
+  [u"name"]=>
+  unicode(3) "Foo"
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_hasProperty_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_hasProperty_basic.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_hasProperty_basic.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_hasProperty_basic.phpt Thu May 
22 21:54:01 2008
@@ -0,0 +1,38 @@
+--TEST--
+ReflectionClass::hasProperty()
+--CREDIT--
+Marc Veldman <[EMAIL PROTECTED]>
+#testfest roosendaal on 2008-05-10
+--FILE-- 
+<?php
+//New instance of class C - defined below
+$rc = new ReflectionClass("C");
+
+//Check if C has public property publicFoo
+var_dump($rc->hasProperty('publicFoo'));
+
+//Check if C has protected property protectedFoo
+var_dump($rc->hasProperty('protectedFoo'));
+
+//Check if C has private property privateFoo
+var_dump($rc->hasProperty('privateFoo'));
+
+//Check if C has static property staticFoo
+var_dump($rc->hasProperty('staticFoo'));
+
+//C should not have property bar
+var_dump($rc->hasProperty('bar'));
+
+Class C {
+  public $publicFoo;
+  protected $protectedFoo;
+  private $privateFoo;
+  public static $staticFoo;
+}
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_getModifiers_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_getModifiers_basic.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_getModifiers_basic.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_getModifiers_basic.phpt        
Thu May 22 21:54:01 2008
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionClass::getModifiers()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <[EMAIL PROTECTED]>
+--FILE--
+<?php
+
+class a {}
+abstract class b {}
+final class c {}
+interface d {}
+class e implements d {}
+interface f extends d {}
+class g extends b {}
+
+function dump_modifiers($class) {
+       $obj = new ReflectionClass($class);
+       var_dump($obj->getModifiers());
+}
+
+dump_modifiers('a');
+dump_modifiers('b');
+dump_modifiers('c');
+dump_modifiers('d');
+dump_modifiers('e');
+dump_modifiers('f');
+dump_modifiers('g');
+
+?>
+--EXPECT--
+int(0)
+int(32)
+int(64)
+int(128)
+int(524288)
+int(524416)
+int(0)
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_isIterateable_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/reflection/tests/reflectionClass_isIterateable_variation1.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_isIterateable_variation1.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_isIterateable_variation1.phpt  
Thu May 22 21:54:01 2008
@@ -0,0 +1,27 @@
+--TEST--
+ReflectionClass::isIterateable() variations
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <[EMAIL PROTECTED]>
+--FILE--
+<?php
+
+class BasicClass {}
+
+function dump_iterateable($obj)
+{
+       $reflection = new ReflectionClass($obj);
+       var_dump($reflection->isIterateable());
+}
+
+$basicClass = new BasicClass();
+$stdClass = new StdClass();
+
+dump_iterateable($basicClass);
+dump_iterateable($stdClass);
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_hasConstant_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/reflectionClass_hasConstant_basic.phpt
diff -u /dev/null 
php-src/ext/reflection/tests/reflectionClass_hasConstant_basic.phpt:1.2
--- /dev/null   Thu May 22 21:54:01 2008
+++ php-src/ext/reflection/tests/reflectionClass_hasConstant_basic.phpt Thu May 
22 21:54:01 2008
@@ -0,0 +1,23 @@
+--TEST--
+ReflectionClass::hasConstant()
+--CREDIT--
+Marc Veldman <[EMAIL PROTECTED]>
+#testfest roosendaal on 2008-05-10
+--FILE-- 
+<?php
+//New instance of class C - defined below
+$rc = new ReflectionClass("C");
+
+//Check if C has constant foo
+var_dump($rc->hasConstant('foo'));
+
+//C should not have constant bar
+var_dump($rc->hasConstant('bar'));
+
+Class C {
+  const foo=1;
+}
+?>
+--EXPECTF--
+bool(true)
+bool(false)

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

Reply via email to