Passed
Push — master ( bff06a...77db42 )
by Alexander
01:45
created

QueryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBooleanValues() 0 33 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Pgsql\Tests;
6
7
use Yiisoft\Db\Querys\Query;
8
use Yiisoft\Db\Tests\QueryTest as AbstractQueryTest;
9
10
class QueryTest extends AbstractQueryTest
11
{
12
    public ?string $driverName = 'pgsql';
13
14
    public function testBooleanValues(): void
15
    {
16
        $db = $this->getConnection();
17
        $command = $db->createCommand();
18
19
        $command->batchInsert(
20
            'bool_values',
21
            ['bool_col'],
22
            [
23
                [true],
24
                [false],
25
            ]
26
        )->execute();
27
28
        $this->assertEquals(1, (new Query($db))->from('bool_values')->where('bool_col = TRUE')->count('*', $db));
0 ignored issues
show
Unused Code introduced by
The call to Yiisoft\Db\Querys\Query::count() has too many arguments starting with $db. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $this->assertEquals(1, (new Query($db))->from('bool_values')->where('bool_col = TRUE')->/** @scrutinizer ignore-call */ count('*', $db));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
29
        $this->assertEquals(1, (new Query($db))->from('bool_values')->where('bool_col = FALSE')->count('*', $db));
30
        $this->assertEquals(
31
            2,
32
            (new Query($db))->from('bool_values')->where('bool_col IN (TRUE, FALSE)')->count('*', $db)
33
        );
34
        $this->assertEquals(1, (new Query($db))->from('bool_values')->where(['bool_col' => true])->count('*', $db));
35
        $this->assertEquals(1, (new Query($db))->from('bool_values')->where(['bool_col' => false])->count('*', $db));
36
        $this->assertEquals(
37
            2,
38
            (new Query($db))->from('bool_values')->where(['bool_col' => [true, false]])->count('*', $db)
39
        );
40
        $this->assertEquals(
41
            1,
42
            (new Query($db))->from('bool_values')->where('bool_col = :bool_col', ['bool_col' => true])->count('*', $db)
43
        );
44
        $this->assertEquals(
45
            1,
46
            (new Query($db))->from('bool_values')->where('bool_col = :bool_col', ['bool_col' => false])->count('*', $db)
47
        );
48
    }
49
}
50