我正在使用 liip-functional-test 包对我的应用程序进行功能测试。我在 config_test.php 文件中配置了一个测试数据库:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: %database_driver_sqlite%
path: %database_path%
当我运行我的测试时,我收到错误:在最后一行断言 false 为 true 失败
public function test()
{
$this->loadFixtures(array(
'UserBundle\DataFixtures\ORM\LoadUserData'
));
$client = static::makeClient(true,
array(
'HTTP_HOST' => 'mylocalhost'
));
$crawler = $client->request('GET', '/login');
$form = $crawler->selectButton('Login')->form(array(
'_username' => 'username',
'_password' => 'password',
),'POST');
echo ' TEST RESULT '.$client->getResponse()->getStatusCode().' ';
$client->submit($form);
$this->assertTrue($client->getResponse()->isRedirect());
$client->followRedirect();
echo ' TEST RESULT '.$client->getResponse()->getStatusCode().' ';
$crawler = $client->request('GET', '/another page');
$this->assertTrue($crawler->filter('html:contains("some_text_on_page")')->count() > 0);
如果我从 config_test 文件中注释测试数据库配置,我的测试运行正常。我想要的只是:在测试数据库中编写夹具并在真实数据库上运行断言和其他测试