Passed
Push — master ( cfe060...447357 )
by Alexander
03:18
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
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Pgsql\Tests;
6
7
use Yiisoft\Db\Query\Query;
8
use Yiisoft\Db\Tests\QueryTest as AbstractQueryTest;
9
10
class QueryTest extends AbstractQueryTest
11
{
12
    protected ?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));
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