根据这个文档,我可以在我的测试类中编写一个setUp()
函数,比如:
use Doctrine\ORM\Tools\SchemaTool;
use Liip\FunctionalTestBundle\Test\WebTestCase;
class AccountControllerTest extends WebTestCase
{
public function setUp()
{
$em = $this->getContainer()->get('doctrine')->getManager();
if (!isset($metadatas)) {
$metadatas = $em->getMetadataFactory()->getAllMetadata();
}
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase();
if (!empty($metadatas)) {
$schemaTool->createSchema($metadatas);
}
$this->postFixtureSetup();
$fixtures = array(
'Acme\MyBundle\DataFixtures\ORM\LoadUserData',
);
$this->loadFixtures($fixtures);
}
//...
}
但是当我setUp()
在扩展的 WebTestCase 类中查找方法时,我没有找到。我的理解是我可以在子类中重新定义父类的方法。父类是:
https://github.com/liip/LiipFunctionalTestBundle/blob/master/Test/WebTestCase.php
请向我解释为什么以及何时执行此方法?谢谢