cvs: php-src /ext/reflection/tests reflectionClass_constructor_001.phpt reflectionClass_constructor_002.phpt
| From: | Zoe Slattery | Date: | Mon, 09 Jul 2007 13:13:35 +0000 |
| Subject: | cvs: php-src /ext/reflection/tests reflectionClass_constructor_001.phpt reflectionClass_constructor_002.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-45140@lists.php.net to get a copy of this message | ||
zoe Mon Jul 9 13:13:35 2007 UTC
Added files:
/php-src/ext/reflection/tests reflectionClass_constructor_001.phpt
reflectionClass_constructor_002.phpt
Log:
ReflectionClass constructor tests
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_constructor_001.phpt?view=markup&rev=1.1
Index: php-src/ext/reflection/tests/reflectionClass_constructor_001.phpt
+++ php-src/ext/reflection/tests/reflectionClass_constructor_001.phpt
--TEST--
ReflectionClass::__constructor()
--FILE--
<?php
$r1 = new ReflectionClass("stdClass");
$myInstance = new stdClass;
$r2 = new ReflectionClass($myInstance);
class TrickClass {
function __toString() {
//Return the name of another class
return "Exception";
}
}
$myTrickClass = new TrickClass;
$r3 = new ReflectionClass($myTrickClass);
var_dump($r1, $r2, $r3);
?>
--EXPECTF--
object(ReflectionClass)#%d (1) {
["name"]=>
string(8) "stdClass"
}
object(ReflectionClass)#%d (1) {
["name"]=>
string(8) "stdClass"
}
object(ReflectionClass)#%d (1) {
["name"]=>
string(10) "TrickClass"
}
--UEXPECTF--
object(ReflectionClass)#%d (1) {
[u"name"]=>
unicode(8) "stdClass"
}
object(ReflectionClass)#%d (1) {
[u"name"]=>
unicode(8) "stdClass"
}
object(ReflectionClass)#%d (1) {
[u"name"]=>
unicode(10) "TrickClass"
}
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionClass_constructor_002.phpt?view=markup&rev=1.1
Index: php-src/ext/reflection/tests/reflectionClass_constructor_002.phpt
+++ php-src/ext/reflection/tests/reflectionClass_constructor_002.phpt
--TEST--
ReflectionClass::__constructor() - bad arguments
--FILE--
<?php
try {
var_dump(new ReflectionClass());
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(new ReflectionClass(null));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(new ReflectionClass(true));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(new ReflectionClass(1));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(new ReflectionClass(array(1,2,3)));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(new ReflectionClass("stdClass", 1));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(new ReflectionClass("X"));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
Warning: ReflectionClass::__construct() expects exactly 1 parameter, 0 given in %s on line 3
object(ReflectionClass)#%d (1) {
["name"]=>
string(0) ""
}
Class does not exist
Class 1 does not exist
Class 1 does not exist
Warning: ReflectionClass::__construct() expects parameter 1 to be string (Unicode or binary), array
given in %s on line 27
object(ReflectionClass)#3 (1) {
["name"]=>
string(0) ""
}
Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33
object(ReflectionClass)#%d (1) {
["name"]=>
string(0) ""
}
Class X does not exist
--UEXPECTF--
Warning: ReflectionClass::__construct() expects exactly 1 parameter, 0 given in %s on line 3
object(ReflectionClass)#%d (1) {
[u"name"]=>
unicode(0) ""
}
Class does not exist
Class 1 does not exist
Class 1 does not exist
Warning: ReflectionClass::__construct() expects parameter 1 to be string (Unicode or binary), array
given in %s on line 27
object(ReflectionClass)#3 (1) {
[u"name"]=>
unicode(0) ""
}
Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33
object(ReflectionClass)#%d (1) {
[u"name"]=>
unicode(0) ""
}
Class X does not exist