I'm doing some functional testing with PHPUnit in Symfony2 .
I use PHPUnit version 4.4.1 ,tests were created with the controller generation (doctrine:generate:crud)
So , I only tests the CRUD on an User, and it takes me more than 30 seconds (This varies between 30 and 40s ) . Is this comes from the code? Tests themselves ? The fact that I worked on a remote server?
Here is the test class :
class UserControllerTest extends WebTestCase
{
/**
* Test CRUD functions (Create, read, update, delete)
*/
public function testCompleteScenario()
{
// Create a new client to browse the application
$client = static::createClient();
// Create a new entry in the database
$crawler = $client->request('GET', '/user/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /user/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
's_dosfabbundle_user[login]' => 'test.test',
's_dosfabbundle_user[trigram]' => 'tet',
's_dosfabbundle_user[email]' => 'test@test.com',
's_dosfabbundle_user[productionUnits]' => '11',
's_dosfabbundle_user[roles]' => '55',
));
$client->submit($form);
$crawler = $client->followRedirect();
// Check data in the show view
$this->assertGreaterThan(0, $crawler->filter('td:contains("test.test")')->count(), 'Missing element td:contains("test.test")');
// Edit the entity
$crawler = $client->click($crawler->selectLink('Edit')->link());
$form = $crawler->selectButton('Update')->form(array(
's_dosfabbundle_user[login]' => 'test.testUpdate',
's_dosfabbundle_user[trigram]' => 'tetU',
's_dosfabbundle_user[email]' => 'test_update@test.com',
's_dosfabbundle_user[productionUnits]' => '11',
's_dosfabbundle_user[roles]' => '57',
));
$client->submit($form);
$crawler = $client->followRedirect();
// Check the element contains an attribute with value equals "Foo"
$this->assertGreaterThan(0, $crawler->filter('[value="tetU"]')->count(), 'Missing element [value="tetU"]');
// Delete the entity
$client->submit($crawler->selectButton('Delete')->form());
$crawler = $client->followRedirect();
// Check the entity has been delete on the list
$this->assertNotRegExp('/tetU/', $client->getResponse()->getContent());
}
}