Menu

#65 Error when TestCase method name equals class name

v1.0 (example)
closed-invalid
1
2005-12-04
2005-12-02
German Rumm
No

When method names is the same as class name,
simpletest gives error:

Fatal error: Call to a member function paintPass() on
a non-object in simpletest/simple_test.php on line 115

Class testBug extends UnitTestCase {
function testBug() {
$this->assertTrue(true);
}
}

$test = new TestBug();
$test->run(new HtmlReporter());

Discussion

  • Marcus Baker

    Marcus Baker - 2005-12-04

    Logged In: YES
    user_id=695819

    Hi.

    With PHP4 (and PHP5 to keep compatibility) a method withthe
    same name as the class is actually the constructor. That is,
    you have overridden the constructor in your example.

    This is a language issue rather than a SimpleTest one I am
    afraid.

    yours, Marcus

     
  • Marcus Baker

    Marcus Baker - 2005-12-04
    • priority: 5 --> 1
    • assigned_to: nobody --> lastcraft
    • status: open --> closed-invalid
     

Log in to post a comment.