In my tests with phpunit and symfony2, I am trying to assess the query count, following the examples in symfony doc.
For some strange reason, the query count is always the same, whatever the page which is loaded.
Can someone help me figure out why ?
My code :
/**
* @dataProvider urlProvider
* @param $url
*/
public function testPageIsSuccessful($url)
{
$client = static::createClient(array(), array(
'PHP_AUTH_USER' => 'superadmin',
'PHP_AUTH_PW' => '587010',
));
$client->enableProfiler();
$client->followRedirects();
$client->request('GET', $url);
var_dump($url);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$queryCount = $client->getProfile()->getCollector('db')->getQueryCount();
var_dump('Q: ' . $queryCount);
$this->assertLessThan(60,$queryCount);
}
the previous code is dumping the following, with a constant number of 18 queries (which does not reflect the reality) :
.string(44) "/foodanalytics/user_supplier/change_supplier"
string(5) "Q: 18"
.string(10) "/dashboard"
string(5) "Q: 18"
.string(34) "/user/associate/display_associates"
string(5) "Q: 18"
.string(46) "/job/application/display_employer_applications"
string(5) "Q: 18"
...
Aucun commentaire:
Enregistrer un commentaire