alexislefebvre /
LiipFunctionalTestBundle
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of the Liip/FunctionalTestBundle |
||
| 7 | * |
||
| 8 | * (c) Lukas Kahwe Smith <[email protected]> |
||
| 9 | * |
||
| 10 | * This source file is subject to the MIT license that is bundled |
||
| 11 | * with this source code in the file LICENSE. |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace Liip\FunctionalTestBundle; |
||
| 15 | |||
| 16 | use Symfony\Bundle\FrameworkBundle\Client; |
||
| 17 | use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass; |
||
| 18 | use Symfony\Bundle\FrameworkBundle\KernelBrowser; |
||
| 19 | |||
| 20 | // Symfony <4 BC |
||
| 21 | 5 | if (class_exists(CompilerDebugDumpPass::class)) { |
|
| 22 | class_alias(QueryCountClientSymfony3Trait::class, QueryCountClientTrait::class); |
||
| 23 | } |
||
| 24 | |||
| 25 | // Symfony <4.3.1 BC |
||
| 26 | 5 | if (!class_exists(KernelBrowser::class)) { |
|
| 27 | class_alias(Client::class, KernelBrowser::class); |
||
| 28 | } |
||
| 29 | |||
| 30 | 5 | if (!class_exists(Client::class)) { |
|
| 31 | class_alias(KernelBrowser::class, Client::class); |
||
| 32 | } |
||
| 33 | |||
| 34 | class QueryCountClient extends KernelBrowser |
||
| 35 | { |
||
| 36 | /* |
||
| 37 | * We use trait only because of Client::request signature strict type mismatch between Symfony 3 and 4. |
||
| 38 | */ |
||
| 39 | use QueryCountClientTrait; |
||
| 40 | |||
| 41 | /** @var QueryCounter */ |
||
| 42 | private $queryCounter; |
||
| 43 | |||
| 44 | 5 | public function setQueryCounter(QueryCounter $queryCounter): void |
|
| 45 | { |
||
| 46 | 5 | $this->queryCounter = $queryCounter; |
|
| 47 | 5 | } |
|
| 48 | |||
| 49 | private function checkQueryCount(): void |
||
| 50 | { |
||
| 51 | if ($this->getProfile()) { |
||
| 52 | $this->queryCounter->checkQueryCount( |
||
| 53 | $this->getProfile()->getCollector('db')->getQueryCount() |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 54 | ); |
||
| 55 | } else { |
||
| 56 | // @codeCoverageIgnoreStart |
||
| 57 | echo "\n". |
||
| 58 | 'Profiler is disabled, it must be enabled for the '. |
||
| 59 | 'Query Counter. '. |
||
| 60 | 'See https://github.com/liip/LiipFunctionalTestBundle#query-counter'. |
||
| 61 | "\n"; |
||
| 62 | // @codeCoverageIgnoreEnd |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 |