问题描述:

I have a set of read-only tests and a couple of ones that modify data (insert/update/delete). I'd like to back up my tables, so each test class would have a list of associated tables that they'll modify. This is just test data.

I thus thought of this:

abstract class DataAlteringTestBase extends PHPUnit_Framework_TestCase

{

protected function setUp()

{

echo "backing up tables: " . $this->GetAlteredTableNames();

}

public abstract function GetAlteredTaleNames();

}

One of the subclasses:

class DataAlteringTest extends DataAlteringTestBase

{

function GetAlteredTaleNames()

{

return array("some_table");

}

public function testDummyStuffChild()

{

$this->assertTrue(true);

}

}

The problem is, I think, that PHPUnit tries to get the method implementation from the abstract class, rather than its children.

Call to undefined method DataAlteringTest::GetAlteredTableNames() -

the implementation ...\tests\DataAlteringTestBase.php:6 - the abstract

class

How to fix it? or is there something wrong with the idea of implementing this in PHP/PHPUnit in the first place?

网友答案:

You have a few typos - you wrote GetAlteredTaleNames() in some places and GetAlteredTableNames() in other places.

相关阅读:
Top