stevseea Tue Dec 18 17:25:40 2007 UTC Modified files: /php-src/ext/reflection/tests reflectionProperty_isDefault_basic.phpt reflectionProperty_basic1.phpt reflectionProperty_getValue_error.phpt reflectionProperty_setValue_error.phpt reflectionProperty_getDocComment_basic.phpt reflectionProperty_basic2.phpt reflectionProperty_getDocComment_error.phpt reflectionProperty_error.phpt reflectionProperty_export_error.phpt reflectionProperty_getModifiers_basic.phpt reflectionProperty_constructor_error.phpt reflectionProperty_export_basic.phpt reflectionProperty_getDeclaringClass_variation1.phpt Log: Adding PHPT tests for the ReflectionProperty class. reflectionProperty_getValue_error.phpt and reflectionProperty_setValue_error.phpt are failing with behaviour that is inconsistent with PHP5_3.
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,65 @@ +--TEST-- +Test ReflectionProperty::isDefault() usage. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +function reflectProperty($class, $property) { + $propInfo = new ReflectionProperty($class, $property); + echo "**********************************\n"; + echo "Reflecting on property $class::$property\n\n"; + echo "isDefault():\n"; + var_dump($propInfo->isDefault()); + echo "\n**********************************\n"; +} + +class TestClass { + public $pub; + static public $stat = "static property"; + protected $prot = 4; + private $priv = "keepOut"; +} + +reflectProperty("TestClass", "pub"); +reflectProperty("TestClass", "stat"); +reflectProperty("TestClass", "prot"); +reflectProperty("TestClass", "priv"); + +echo "Wrong number of params:\n"; +$propInfo = new ReflectionProperty('TestClass', 'pub'); +$propInfo->isDefault(1); + +?> +--EXPECTF-- +********************************** +Reflecting on property TestClass::pub + +isDefault(): +bool(true) + +********************************** +********************************** +Reflecting on property TestClass::stat + +isDefault(): +bool(true) + +********************************** +********************************** +Reflecting on property TestClass::prot + +isDefault(): +bool(true) + +********************************** +********************************** +Reflecting on property TestClass::priv + +isDefault(): +bool(true) + +********************************** +Wrong number of params: + +Warning: Wrong parameter count for ReflectionProperty::isDefault() in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_basic1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_basic1.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_basic1.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_basic1.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,271 @@ +--TEST-- +Test usage of ReflectionProperty methods __toString(), export(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue(). +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +function reflectProperty($class, $property) { + $propInfo = new ReflectionProperty($class, $property); + echo "**********************************\n"; + echo "Reflecting on property $class::$property\n\n"; + echo "__toString():\n"; + var_dump($propInfo->__toString()); + echo "export():\n"; + var_dump(ReflectionProperty::export($class, $property, true)); + echo "export():\n"; + var_dump(ReflectionProperty::export($class, $property, false)); + echo "getName():\n"; + var_dump($propInfo->getName()); + echo "isPublic():\n"; + var_dump($propInfo->isPublic()); + echo "isPrivate():\n"; + var_dump($propInfo->isPrivate()); + echo "isProtected():\n"; + var_dump($propInfo->isProtected()); + echo "isStatic():\n"; + var_dump($propInfo->isStatic()); + $instance = new $class(); + if ($propInfo->isPublic()) { + echo "getValue():\n"; + var_dump($propInfo->getValue($instance)); + $propInfo->setValue($instance, "NewValue"); + echo "getValue() after a setValue():\n"; + var_dump($propInfo->getValue($instance)); + } + echo "\n**********************************\n"; +} + +class TestClass { + public $pub; + static public $stat = "static property"; + protected $prot = 4; + private $priv = "keepOut"; +} + +reflectProperty("TestClass", "pub"); +reflectProperty("TestClass", "stat"); +reflectProperty("TestClass", "prot"); +reflectProperty("TestClass", "priv"); + +?> +--EXPECT-- +********************************** +Reflecting on property TestClass::pub + +__toString(): +string(35) "Property [ <default> public $pub ] +" +export(): +string(35) "Property [ <default> public $pub ] +" +export(): +Property [ <default> public $pub ] + +NULL +getName(): +string(3) "pub" +isPublic(): +bool(true) +isPrivate(): +bool(false) +isProtected(): +bool(false) +isStatic(): +bool(false) +getValue(): +NULL +getValue() after a setValue(): +string(8) "NewValue" + +********************************** +********************************** +Reflecting on property TestClass::stat + +__toString(): +string(33) "Property [ public static $stat ] +" +export(): +string(33) "Property [ public static $stat ] +" +export(): +Property [ public static $stat ] + +NULL +getName(): +string(4) "stat" +isPublic(): +bool(true) +isPrivate(): +bool(false) +isProtected(): +bool(false) +isStatic(): +bool(true) +getValue(): +string(15) "static property" +getValue() after a setValue(): +string(8) "NewValue" + +********************************** +********************************** +Reflecting on property TestClass::prot + +__toString(): +string(39) "Property [ <default> protected $prot ] +" +export(): +string(39) "Property [ <default> protected $prot ] +" +export(): +Property [ <default> protected $prot ] + +NULL +getName(): +string(4) "prot" +isPublic(): +bool(false) +isPrivate(): +bool(false) +isProtected(): +bool(true) +isStatic(): +bool(false) + +********************************** +********************************** +Reflecting on property TestClass::priv + +__toString(): +string(37) "Property [ <default> private $priv ] +" +export(): +string(37) "Property [ <default> private $priv ] +" +export(): +Property [ <default> private $priv ] + +NULL +getName(): +string(4) "priv" +isPublic(): +bool(false) +isPrivate(): +bool(true) +isProtected(): +bool(false) +isStatic(): +bool(false) + +********************************** +--UEXPECT-- +********************************** +Reflecting on property TestClass::pub + +__toString(): +unicode(35) "Property [ <default> public $pub ] +" +export(): +unicode(35) "Property [ <default> public $pub ] +" +export(): +Property [ <default> public $pub ] + +NULL +getName(): +unicode(3) "pub" +isPublic(): +bool(true) +isPrivate(): +bool(false) +isProtected(): +bool(false) +isStatic(): +bool(false) +getValue(): +NULL +getValue() after a setValue(): +unicode(8) "NewValue" + +********************************** +********************************** +Reflecting on property TestClass::stat + +__toString(): +unicode(33) "Property [ public static $stat ] +" +export(): +unicode(33) "Property [ public static $stat ] +" +export(): +Property [ public static $stat ] + +NULL +getName(): +unicode(4) "stat" +isPublic(): +bool(true) +isPrivate(): +bool(false) +isProtected(): +bool(false) +isStatic(): +bool(true) +getValue(): +unicode(15) "static property" +getValue() after a setValue(): +unicode(8) "NewValue" + +********************************** +********************************** +Reflecting on property TestClass::prot + +__toString(): +unicode(39) "Property [ <default> protected $prot ] +" +export(): +unicode(39) "Property [ <default> protected $prot ] +" +export(): +Property [ <default> protected $prot ] + +NULL +getName(): +unicode(4) "prot" +isPublic(): +bool(false) +isPrivate(): +bool(false) +isProtected(): +bool(true) +isStatic(): +bool(false) + +********************************** +********************************** +Reflecting on property TestClass::priv + +__toString(): +unicode(37) "Property [ <default> private $priv ] +" +export(): +unicode(37) "Property [ <default> private $priv ] +" +export(): +Property [ <default> private $priv ] + +NULL +getName(): +unicode(4) "priv" +isPublic(): +bool(false) +isPrivate(): +bool(true) +isProtected(): +bool(false) +isStatic(): +bool(false) + +********************************** + + http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_getValue_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_getValue_error.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_getValue_error.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_getValue_error.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,113 @@ +--TEST-- +Test ReflectionProperty::getValue() errors. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class TestClass { + public $pub; + public $pub2 = 5; + static public $stat = "static property"; + protected $prot = 4; + private $priv = "keepOut"; +} + +class AnotherClass { +} + +$instance = new TestClass(); +$instanceWithNoProperties = new AnotherClass(); +$propInfo = new ReflectionProperty('TestClass', 'pub2'); + +echo "Too few args:\n"; +var_dump($propInfo->getValue()); + +echo "\nToo many args:\n"; +var_dump($propInfo->getValue($instance, true)); + +echo "\nWrong type of arg:\n"; +var_dump($propInfo->getValue(true)); + +echo "\nInstance without property:\n"; +$propInfo = new ReflectionProperty('TestClass', 'stat'); + +echo "\nStatic property / too many args:\n"; +var_dump($propInfo->getValue($instance, true)); + +echo "\nStatic property / wrong type of arg:\n"; +var_dump($propInfo->getValue(true)); + +echo "\nProtected property:\n"; +try { + $propInfo = new ReflectionProperty('TestClass', 'prot'); + var_dump($propInfo->getValue($instance)); +} +catch(Exception $exc) { + echo $exc->getMessage(); +} + +echo "\n\nInstance without property:\n"; +$propInfo = new ReflectionProperty('TestClass', 'pub2'); +var_dump($propInfo->getValue($instanceWithNoProperties)); + +?> +--EXPECTF-- +Too few args: + +Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Too many args: + +Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Wrong type of arg: + +Warning: ReflectionProperty::getValue() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Instance without property: + +Static property / too many args: +string(15) "static property" + +Static property / wrong type of arg: +string(15) "static property" + +Protected property: +Cannot access non-public member TestClass::prot + +Instance without property: +NULL +--UEXPECTF-- +Too few args: + +Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Too many args: + +Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Wrong type of arg: + +Warning: ReflectionProperty::getValue() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Instance without property: + +Static property / too many args: +unicode(15) "static property" + +Static property / wrong type of arg: +unicode(15) "static property" + +Protected property: +Cannot access non-public member TestClass::prot + +Instance without property: +NULL + \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_setValue_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_setValue_error.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_setValue_error.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_setValue_error.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,145 @@ +--TEST-- +Test ReflectionProperty::setValue() error cases. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class TestClass { + public $pub; + public $pub2 = 5; + static public $stat = "static property"; + protected $prot = 4; + private $priv = "keepOut"; +} + +class AnotherClass { +} + +$instance = new TestClass(); +$instanceWithNoProperties = new AnotherClass(); +$propInfo = new ReflectionProperty('TestClass', 'pub2'); + +echo "Too few args:\n"; +var_dump($propInfo->setValue()); +var_dump($propInfo->setValue($instance)); + +echo "\nToo many args:\n"; +var_dump($propInfo->setValue($instance, "NewValue", true)); + +echo "\nWrong type of arg:\n"; +var_dump($propInfo->setValue(true, "NewValue")); +$propInfo = new ReflectionProperty('TestClass', 'stat'); + +echo "\nStatic property / too many args:\n"; +var_dump($propInfo->setValue($instance, "NewValue", true)); + +echo "\nStatic property / too few args:\n"; +var_dump($propInfo->setValue("A new value")); +var_dump(TestClass::$stat); +var_dump($propInfo->setValue()); +var_dump(TestClass::$stat); + +echo "\nStatic property / wrong type of arg:\n"; +var_dump($propInfo->setValue(true, "Another new value")); +var_dump(TestClass::$stat); + +echo "\nProtected property:\n"; +try { + $propInfo = new ReflectionProperty('TestClass', 'prot'); + var_dump($propInfo->setValue($instance, "NewValue")); +} +catch(Exception $exc) { + echo $exc->getMessage(); +} + +echo "\n\nInstance without property:\n"; +$propInfo = new ReflectionProperty('TestClass', 'pub2'); +var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue")); +var_dump($instanceWithNoProperties->pub2); +?> +--EXPECTF-- +Too few args: + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 1 given in %s on line %d +NULL + +Too many args: + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Wrong type of arg: + +Warning: ReflectionProperty::setValue() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Static property / too many args: + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Static property / too few args: +NULL +string(11) "A new value" + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d +NULL +string(11) "A new value" + +Static property / wrong type of arg: +NULL +string(17) "Another new value" + +Protected property: +Cannot access non-public member TestClass::prot + +Instance without property: +NULL +string(8) "NewValue" +--UEXPECTF-- +Too few args: + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 1 given in %s on line %d +NULL + +Too many args: + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Wrong type of arg: + +Warning: ReflectionProperty::setValue() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Static property / too many args: + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Static property / too few args: +NULL +unicode(11) "A new value" + +Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d +NULL +unicode(11) "A new value" + +Static property / wrong type of arg: +NULL +unicode(17) "Another new value" + +Protected property: +Cannot access non-public member TestClass::prot + +Instance without property: +NULL +unicode(8) "NewValue" + \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,160 @@ +--TEST-- +Test ReflectionProperty::getDocComment() usage. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class A { + /** + * My Doc Comment for $a + * + */ + public $a = 2, $b, $c = 1; + /** + * My Doc Comment for $d + */ + var $d; + /**Not a doc comment */ + private $e; + /** + * Doc comment for $f + */ + static protected $f; +} + +class B extends A { + public $a = 2; + /** A doc comment for $b */ + var $b, $c = 1; + /** A doc comment for $e */ + var $e; +} + +foreach(array('A', 'B') as $class) { + $rc = new ReflectionClass($class); + $rps = $rc->getProperties(); + foreach($rps as $rp) { + echo "\n\n---> Doc comment for $class::$" . $rp->getName() . ":\n"; + var_dump($rp->getDocComment()); + } +} + +?> +--EXPECTF-- + +---> Doc comment for A::$a: +string(%d) "/** + * My Doc Comment for $a + * + */" + + +---> Doc comment for A::$b: +bool(false) + + +---> Doc comment for A::$c: +bool(false) + + +---> Doc comment for A::$d: +string(%d) "/** + * My Doc Comment for $d + */" + + +---> Doc comment for A::$e: +bool(false) + + +---> Doc comment for A::$f: +string(%d) "/** + * Doc comment for $f + */" + + +---> Doc comment for B::$a: +bool(false) + + +---> Doc comment for B::$b: +string(%d) "/** A doc comment for $b */" + + +---> Doc comment for B::$c: +bool(false) + + +---> Doc comment for B::$e: +string(%d) "/** A doc comment for $e */" + + +---> Doc comment for B::$d: +string(%d) "/** + * My Doc Comment for $d + */" + + +---> Doc comment for B::$f: +string(%d) "/** + * Doc comment for $f + */" +--UEXPECT-- +---> Doc comment for A::$a: +unicode(47) "/** + * My Doc Comment for $a + * + */" + + +---> Doc comment for A::$b: +bool(false) + + +---> Doc comment for A::$c: +bool(false) + + +---> Doc comment for A::$d: +unicode(40) "/** + * My Doc Comment for $d + */" + + +---> Doc comment for A::$e: +bool(false) + + +---> Doc comment for A::$f: +unicode(37) "/** + * Doc comment for $f + */" + + +---> Doc comment for B::$a: +bool(false) + + +---> Doc comment for B::$b: +unicode(27) "/** A doc comment for $b */" + + +---> Doc comment for B::$c: +bool(false) + + +---> Doc comment for B::$e: +unicode(27) "/** A doc comment for $e */" + + +---> Doc comment for B::$d: +unicode(40) "/** + * My Doc Comment for $d + */" + + +---> Doc comment for B::$f: +unicode(37) "/** + * Doc comment for $f + */" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_basic2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_basic2.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_basic2.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_basic2.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,172 @@ +--TEST-- +Test usage of ReflectionProperty methods isDefault(), getModifiers(), getDeclaringClass() and getDocComment(). +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +function reflectProperty($class, $property) { + $propInfo = new ReflectionProperty($class, $property); + echo "**********************************\n"; + echo "Reflecting on property $class::$property\n\n"; + echo "isDefault():\n"; + var_dump($propInfo->isDefault()); + echo "getModifiers():\n"; + var_dump($propInfo->getModifiers()); + echo "getDeclaringClass():\n"; + var_dump($propInfo->getDeclaringClass()); + echo "getDocComment():\n"; + var_dump($propInfo->getDocComment()); + echo "\n**********************************\n"; +} + +class TestClass { + public $pub; + static public $stat = "static property"; + /** + * This property has a comment. + */ + protected $prot = 4; + private $priv = "keepOut"; +} + +reflectProperty("TestClass", "pub"); +reflectProperty("TestClass", "stat"); +reflectProperty("TestClass", "prot"); +reflectProperty("TestClass", "priv"); + +?> +--EXPECTF-- +********************************** +Reflecting on property TestClass::pub + +isDefault(): +bool(true) +getModifiers(): +int(256) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + ["name"]=> + string(9) "TestClass" +} +getDocComment(): +bool(false) + +********************************** +********************************** +Reflecting on property TestClass::stat + +isDefault(): +bool(true) +getModifiers(): +int(257) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + ["name"]=> + string(9) "TestClass" +} +getDocComment(): +bool(false) + +********************************** +********************************** +Reflecting on property TestClass::prot + +isDefault(): +bool(true) +getModifiers(): +int(512) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + ["name"]=> + string(9) "TestClass" +} +getDocComment(): +string(%d) "/** + * This property has a comment. + */" + +********************************** +********************************** +Reflecting on property TestClass::priv + +isDefault(): +bool(true) +getModifiers(): +int(1024) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + ["name"]=> + string(9) "TestClass" +} +getDocComment(): +bool(false) + +********************************** +--UEXPECTF-- +********************************** +Reflecting on property TestClass::pub + +isDefault(): +bool(true) +getModifiers(): +int(256) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + [u"name"]=> + unicode(9) "TestClass" +} +getDocComment(): +bool(false) + +********************************** +********************************** +Reflecting on property TestClass::stat + +isDefault(): +bool(true) +getModifiers(): +int(257) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + [u"name"]=> + unicode(9) "TestClass" +} +getDocComment(): +bool(false) + +********************************** +********************************** +Reflecting on property TestClass::prot + +isDefault(): +bool(true) +getModifiers(): +int(512) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + [u"name"]=> + unicode(9) "TestClass" +} +getDocComment(): +unicode(47) "/** + * This property has a comment. + */" + +********************************** +********************************** +Reflecting on property TestClass::priv + +isDefault(): +bool(true) +getModifiers(): +int(1024) +getDeclaringClass(): +object(ReflectionClass)#%d (1) { + [u"name"]=> + unicode(9) "TestClass" +} +getDocComment(): +bool(false) + +********************************** http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,31 @@ +--TEST-- +Test ReflectionProperty::getDocComment() errors. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class C { + public $a; +} + +$rc = new ReflectionProperty('C', 'a'); +var_dump($rc->getDocComment(null)); +var_dump($rc->getDocComment('X')); +var_dump($rc->getDocComment(true)); +var_dump($rc->getDocComment(array(1, 2, 3))); + +?> +--EXPECTF-- + +Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d +NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_error.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_error.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_error.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,114 @@ +--TEST-- +Test ReflectionProperty class errors. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class C { + public static $p; +} + +var_dump(new ReflectionProperty()); +var_dump(new ReflectionProperty('C::p')); +var_dump(new ReflectionProperty('C', 'p', 'x')); +$rp = new ReflectionProperty('C', 'p'); +var_dump($rp->getName(1)); +var_dump($rp->isPrivate(1)); +var_dump($rp->isProtected(1)); +var_dump($rp->isPublic(1)); +var_dump($rp->isStatic(1)); +var_dump($rp->getModifiers(1)); +var_dump($rp->isDefault(1)); + +?> +--EXPECTF-- +Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 0 given in %s on line %d +object(ReflectionProperty)#%d (2) { + ["name"]=> + string(0) "" + ["class"]=> + string(0) "" +} + +Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 1 given in %s on line %d +object(ReflectionProperty)#%d (2) { + ["name"]=> + string(0) "" + ["class"]=> + string(0) "" +} + +Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 3 given in %s on line %d +object(ReflectionProperty)#%d (2) { + ["name"]=> + string(0) "" + ["class"]=> + string(0) "" +} + +Warning: Wrong parameter count for ReflectionProperty::getName() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isPrivate() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isProtected() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isPublic() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isStatic() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::getModifiers() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isDefault() in %s on line %d +NULL +--UEXPECTF-- +Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 0 given in %s on line %d +object(ReflectionProperty)#%d (2) { + [u"name"]=> + unicode(0) "" + [u"class"]=> + unicode(0) "" +} + +Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 1 given in %s on line %d +object(ReflectionProperty)#%d (2) { + [u"name"]=> + unicode(0) "" + [u"class"]=> + unicode(0) "" +} + +Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 3 given in %s on line %d +object(ReflectionProperty)#%d (2) { + [u"name"]=> + unicode(0) "" + [u"class"]=> + unicode(0) "" +} + +Warning: Wrong parameter count for ReflectionProperty::getName() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isPrivate() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isProtected() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isPublic() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isStatic() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::getModifiers() in %s on line %d +NULL + +Warning: Wrong parameter count for ReflectionProperty::isDefault() in %s on line %d +NULL \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_export_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_export_error.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_export_error.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_export_error.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,56 @@ +--TEST-- +Test ReflectionProperty::export() errors. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class TestClass { +} + +$a = 5; + +echo "Non-existent class:\n"; +try { + ReflectionProperty::export("NonExistentClass", "prop", true); +} +catch(Exception $e) { + echo $e->getMessage(); +} + +echo "\n\nWrong property parameter type:\n"; +try { + ReflectionProperty::export($a, 'TestClass', false); +} +catch(ReflectionException $e) { + echo $e->getMessage(); +} + +echo "\n\nNon-existent property:\n"; +try { + ReflectionProperty::export('TestClass', "nonExistentProperty", true); +} +catch(Exception $e) { + echo $e->getMessage(); +} + +echo "\n\nIncorrect number of args:\n"; +ReflectionProperty::export(); +ReflectionProperty::export('TestClass', "nonExistentProperty", true, false); + +?> +--EXPECTF-- +Non-existent class: +Class NonExistentClass does not exist + +Wrong property parameter type: +The parameter class is expected to be either a string or an object + +Non-existent property: +Property TestClass::$nonExistentProperty does not exist + +Incorrect number of args: + +Warning: ReflectionProperty::export() expects at least 2 parameters, 0 given in %s on line %d + +Warning: ReflectionProperty::export() expects at most 3 parameters, 4 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,48 @@ +--TEST-- +Test ReflectionProperty::getModifiers() usage. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class C { + public $a1; + protected $a2; + private $a3; + static public $a4; + static protected $a5; + static private $a6; +} + +class D extends C { + public $a1; + protected $a2; + private $a3; + static public $a4; + static protected $a5; + static private $a6; +} + +for ($i = 1;$i <= 6;$i++) { + $rp = new ReflectionProperty("C", "a$i"); + echo "C::a$i: "; + var_dump($rp->getModifiers()); + $rp = new ReflectionProperty("D", "a$i"); + echo "D::a$i: "; + var_dump($rp->getModifiers()); +} + +?> +--EXPECTF-- +C::a1: int(256) +D::a1: int(256) +C::a2: int(512) +D::a2: int(512) +C::a3: int(1024) +D::a3: int(3072) +C::a4: int(257) +D::a4: int(257) +C::a5: int(513) +D::a5: int(513) +C::a6: int(1025) +D::a6: int(3073) \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_constructor_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_constructor_error.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_constructor_error.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_constructor_error.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,46 @@ +--TEST-- +Test ReflectionProperty class constructor errors. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class TestClass { +} + +$a = 5; + +echo "Non-existent class:\n"; +try { + $propInfo = new ReflectionProperty("NonExistentClass", "prop"); +} +catch(Exception $e) { + echo $e->getMessage(); +} + +echo "\n\nWrong property parameter type:\n"; +try { + $propInfo = new ReflectionProperty($a, 'TestClass'); +} +catch(ReflectionException $e) { + echo $e->getMessage(); +} + +echo "\n\nNon-existent property:\n"; +try { + $propInfo = new ReflectionProperty('TestClass', "nonExistentProperty"); +} +catch(Exception $e) { + echo $e->getMessage(); +} + +?> +--EXPECT-- +Non-existent class: +Class NonExistentClass does not exist + +Wrong property parameter type: +The parameter class is expected to be either a string or an object + +Non-existent property: +Property TestClass::$nonExistentProperty does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_export_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_export_basic.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_export_basic.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_export_basic.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,18 @@ +--TEST-- +Test ReflectionProperty::export() usage. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class TestClass { + public $proper = 5; +} + +var_dump(ReflectionProperty::export('TestClass', 'proper')); + +?> +--EXPECT-- +Property [ <default> public $proper ] + +NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt diff -u /dev/null php-src/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt:1.2 --- /dev/null Tue Dec 18 17:25:40 2007 +++ php-src/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt Tue Dec 18 17:25:40 2007 @@ -0,0 +1,37 @@ +--TEST-- +Test ReflectionProperty::getDeclaringClass() with inherited properties. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +class A { + public $prop; +} + +class B extends A { +} + +$propInfo = new ReflectionProperty('B', 'prop'); +var_dump($propInfo->getDeclaringClass()); + +echo "Wrong number of params:\n"; +$propInfo->getDeclaringClass(1); + +?> +--EXPECTF-- +object(ReflectionClass)#%d (1) { + ["name"]=> + string(1) "A" +} +Wrong number of params: + +Warning: Wrong parameter count for ReflectionProperty::getDeclaringClass() in %s on line %d +--UEXPECTF-- +object(ReflectionClass)#%d (1) { + [u"name"]=> + unicode(1) "A" +} +Wrong number of params: + +Warning: Wrong parameter count for ReflectionProperty::getDeclaringClass() in %s on line %d \ No newline at end of file
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php