Symfony functional testing using two databases

527 Views Asked by At

I'm using liip-functional-test bundle for functional testing my application. I configured a test database in the config_test.php file:

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   %database_driver_sqlite%
                path:     %database_path%

When i run my tests i get the error : Failed asserting that false is true on the last line

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);

If i comment the test database configuration from config_test file, my tests run ok. All i want is something like: write fixtures in the test database and run asserts and other tests on the real database

0

There are 0 best solutions below