Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.2

Bug #2875 example from PHPUnit.php does not work
Submitted: 2004-12-02 16:09 UTC
From: christian at wenz dot org Assigned:
Status: Bogus Package: PHPUnit
PHP Version: 4.3.10RC1 OS: WinXP
Roadmaps: (Not assigned)    
Subscription  


 [2004-12-02 16:09 UTC] christian at wenz dot org
Description: ------------ I just played around with PHPUnit and PHP 4.3.10RC1 (usually I am using PHPUnit2) and stumbled upon this: The MathTest code from PHPUnit.php (v1.13) returns the following error: Fatal error: Call to a member function on a non-object in /path/to/pear/PHPUnit/TestResult.php on line 276 To fix, change TestResult.php Lines 275-276. Old: get_class($passedTest), $passedTest->getName() New: get_class($passedTest[0]), $passedTest[0]->getName() Line 281. Old: $result .= $failedTest->toString(); New: $result .= $failedTest[0]->toString(); But maybe something else triggered this?! Reproduce code: --------------- <?php require_once 'PHPUnit.php'; class MathTest extends PHPUnit_TestCase { var $fValue1; var $fValue2; function MathTest($name) { $this->PHPUnit_TestCase($name); } function setUp() { $this->fValue1 = 2; $this->fValue2 = 3; } function testAdd() { $this->assertTrue($this->fValue1 + $this->fValue2 == 5); } } $suite = new PHPUnit_TestSuite(); $suite->addTest(new MathTest('testAdd')); $result = PHPUnit::run($suite); print $result->toHTML(); ?> Expected result: ---------------- TestCase mathtest->testAdd() passed Actual result: -------------- Fatal error: Call to a member function on a non-object in /path/to/pear/PHPUnit/TestResult.php on line 276

Comments

 [2004-12-02 16:44 UTC] christian at wenz dot org
oh no ... with 4.3.9, it works as expected. So this is most certainly a bug with PHP 4.3.10RC1. Maybe anyone who knows the internals of PHPUnit1 better than I do can find out easily what the real issue is (and file a PHP bug report)?