forked from liip/LiipFunctionalTestBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QueryCountClient.php
44 lines (37 loc) · 1.16 KB
/
QueryCountClient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Liip\FunctionalTestBundle;
use Symfony\Bundle\FrameworkBundle\Client;
class QueryCountClient extends Client
{
/** @var QueryCounter */
private $queryCounter;
public function setQueryCounter(QueryCounter $queryCounter)
{
$this->queryCounter = $queryCounter;
}
public function request(
$method,
$uri,
array $parameters = array(),
array $files = array(),
array $server = array(),
$content = null,
$changeHistory = true
) {
$crawler = parent::request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
if ($this->getProfile()) {
$this->queryCounter->checkQueryCount(
$this->getProfile()->getCollector('db')->getQueryCount()
);
} else {
// @codeCoverageIgnoreStart
echo "\n".
'Profiler is disabled, it must be enabled for the '.
'Query Counter. '.
'See https://github.com/liip/LiipFunctionalTestBundle#query-counter'.
"\n";
// @codeCoverageIgnoreEnd
}
return $crawler;
}
}