我仍在进行 PHP 单元测试以测试我的 symfony2 控制器。我的测试类是 WebTestCase 的派生,并且测试正在执行 GET 或 POST 请求,以检查一切是否正常。我想测试所有底层,但我不想让我的数据库被测试弄乱。我不想使用模型,而是使用内存中的 SQLite db,我可以在其中设置测试场景来检查所有修改。我发现了很多提示如何使用学说 1.x 做到这一点,但它们不再起作用了。所以我想要这样的东西:
class BlahblahTest extends WebTestCase {
public function testXXXYYY() {
// 1. Setup a new database with SQLite:memory:
// 2. create the database and all tables according the entities in my project
$this->createTestScenario(); // 3.
$crawler = $this->client->request('GET', '/testpage'); // 4.
// 5. Lots of checks against the database and / or the $crawler data
}
}
有机会得到这份工作吗?
在此先感谢亨内斯