Sebastian Bergmann wrote:
> In PHPUnit2 I have the following code:
It seems that I have been at slightly the wrong code
try {
$class = new ReflectionClass($this);
var_dump($this);
$method = $class->getMethod($this->name);
var_dump($this);
exit;
}
object(BankAccountTest)#38 (2) {
["codeCoverageInformation:private"]=>
array(0) {
}
["name:private"]=>
string(14) "testGetBalance"
}
object(BankAccountTest)#38 (2) {
["codeCoverageInformation:private"]=>
array(0) {
}
["name:private"]=>
string(14) "testgetbalance"
}
So it looks like calling getMethod() on a ReflectionClass object for
the current object lowercases the contents of the variable that is
passed to it.
Hardcoding the getMethod() parameter prevents the lowercasing
try {
$class = new ReflectionClass($this);
var_dump($this);
$method = $class->getMethod('testGetBalance');
var_dump($this);
exit;
}
object(BankAccountTest)#38 (2) {
["codeCoverageInformation:private"]=>
array(0) {
}
["name:private"]=>
string(14) "testGetBalance"
}
object(BankAccountTest)#38 (2) {
["codeCoverageInformation:private"]=>
array(0) {
}
["name:private"]=>
string(14) "testGetBalance"
}
while copying the value from $this->name to $name and passing that to
getMethod() does not
try {
$class = new ReflectionClass($this);
var_dump($this);
$name = $this->name;
$method = $class->getMethod($name);
var_dump($this);
exit;
}
object(BankAccountTest)#38 (2) {
["codeCoverageInformation:private"]=>
array(0) {
}
["name:private"]=>
string(14) "testGetBalance"
}
object(BankAccountTest)#38 (2) {
["codeCoverageInformation:private"]=>
array(0) {
}
["name:private"]=>
string(14) "testgetbalance"
}
Sorry for these lengthy mails but this issue is important to me as it
hinders the development of PHPUnit2.
--
Sebastian Bergmann http://www.sebastian-bergmann.de/
GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php