note 56117 rejected from function.get-class by betz

From: Date: Wed, 24 Aug 2005 06:50:27 +0000
Subject: note 56117 rejected from function.get-class by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94111@lists.php.net to get a copy of this message
Note Submitter: winescout at yahoo dot com ---- I believe this to be a bug, but its behavior is worth noting here. When calling the static function of a parent class, get_class() returns the name of the parent, as does __CLASS__. <?php require_once 'PHPUnit2/Framework/TestCase.php'; class StaticInheritanceTest extends PHPUnit2_Framework_TestCase { public function testClassVariable(){ $this->assertEquals("Child",Child::getClassVariableValue()); } public function testClassMethodValue(){ $this->assertEquals("Child",Child::getClassMethodValue()); } } class Elder{ static function getClassVariableValue(){ return __CLASS__; } static function getClassMethodValue(){ return get_class(); } } class Child extends Elder{ } ?> Here is the result -- There were 2 failures: 1) testClasVariable(StaticInheritanceTest) expected: <Child> but was: <Elder> 2) testClassMethodValue(StaticInheritanceTest) expected: <Child> but was: <Elder> FAILURES!!! Tests run: 2, Failures: 2, Errors: 0, Incomplete Tests: 0.

« previous php.notes (#94111) next »