These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace Portiny\Doctrine\Tests\Adapter\Nette\Tracy; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Portiny\Doctrine\Adapter\Nette\Tracy\DoctrineSQLPanel; |
||
7 | use Portiny\Doctrine\Tests\AbstractContainerTestCase; |
||
8 | |||
9 | class DoctrineSQLPanelTest extends AbstractContainerTestCase |
||
10 | { |
||
11 | /** |
||
12 | * @var DoctrineSQLPanel |
||
13 | */ |
||
14 | private $doctrineSQLPanel; |
||
15 | |||
16 | protected function setUp(): void |
||
17 | { |
||
18 | parent::setUp(); |
||
19 | |||
20 | /** @var EntityManager $entityManager */ |
||
21 | $entityManager = $this->container->getByType(EntityManager::class); |
||
22 | $this->doctrineSQLPanel = new DoctrineSQLPanel($entityManager); |
||
23 | } |
||
24 | |||
25 | public function testStartQuery(): void |
||
26 | { |
||
27 | $this->doctrineSQLPanel->startQuery('SELECT 1 FROM dual', NULL, NULL); |
||
28 | $this->doctrineSQLPanel->stopQuery(); |
||
29 | |||
30 | $queries = $this->doctrineSQLPanel->getQueries(); |
||
31 | $this->assertCount(1, $queries); |
||
0 ignored issues
–
show
|
|||
32 | $this->assertSame('SELECT 1 FROM dual', reset($queries)[0]); |
||
33 | } |
||
34 | |||
35 | public function testStopQuery(): void |
||
36 | { |
||
37 | $this->doctrineSQLPanel->startQuery('SELECT 1 FROM dual', NULL, NULL); |
||
38 | sleep(1); |
||
39 | $this->doctrineSQLPanel->stopQuery(); |
||
40 | |||
41 | $queries = $this->doctrineSQLPanel->getQueries(); |
||
42 | $firstQuery = reset($queries); |
||
43 | |||
44 | $this->assertCount(1, $queries); |
||
0 ignored issues
–
show
$queries is of type array , but the function expects a object<Countable>|object...nit\Framework\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
45 | $this->assertSame('SELECT 1 FROM dual', $firstQuery[0]); |
||
46 | $this->assertTrue($firstQuery[3] > 0); |
||
47 | } |
||
48 | |||
49 | public function testGetTab(): void |
||
50 | { |
||
51 | $this->assertContains('<span title="Doctrine 2">', $this->doctrineSQLPanel->getTab()); |
||
52 | $this->assertContains('0 queries', $this->doctrineSQLPanel->getTab()); |
||
53 | |||
54 | $this->doctrineSQLPanel->startQuery('SELECT 1 FROM dual', NULL, NULL); |
||
55 | $this->doctrineSQLPanel->stopQuery(); |
||
56 | |||
57 | $this->assertContains('1 queries', $this->doctrineSQLPanel->getTab()); |
||
58 | } |
||
59 | |||
60 | public function testGetPanel(): void |
||
61 | { |
||
62 | $this->assertContains('<h2>Queries</h2>', $this->doctrineSQLPanel->getPanel()); |
||
63 | |||
64 | $this->doctrineSQLPanel->startQuery('SELECT 1 FROM dual', NULL, NULL); |
||
65 | $this->doctrineSQLPanel->stopQuery(); |
||
66 | |||
67 | $this->assertContains('<h1>Queries: 1, time:', $this->doctrineSQLPanel->getPanel()); |
||
68 | } |
||
69 | } |
||
70 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: