Passed
Push — master ( 5adaea...ab4b97 )
by Alexander
01:37
created

QueryTest::testLimitOffsetWithExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite\Tests;
6
7
use Yiisoft\Db\Expressions\Expression;
8
use Yiisoft\Db\Querys\Query;
9
use Yiisoft\Db\Tests\QueryTest as AbstractQueryTest;
10
11
class QueryTest extends AbstractQueryTest
12
{
13
    protected ?string $driverName = 'sqlite';
14
15
    public function testUnion(): void
16
    {
17
        $db = $this->getConnection();
18
19
        $query = new Query($db);
20
21
        $query->select(['id', 'name'])
22
            ->from('item')
23
            ->union(
24
                (new Query($db))
25
                    ->select(['id', 'name'])
26
                    ->from(['category'])
27
            );
28
29
        $result = $query->all();
30
31
        $this->assertNotEmpty($result);
32
        $this->assertCount(7, $result);
33
    }
34
35
    public function testLimitOffsetWithExpression(): void
36
    {
37
        $query = (new Query($this->getConnection()))->from('customer')->select('id')->orderBy('id');
38
39
        $query
40
            ->limit(new Expression('1 + 1'))
41
            ->offset(new Expression('1 + 0'));
42
43
        $result = $query->column();
44
45
        $this->assertCount(2, $result);
46
        $this->assertContains("2", $result);
47
        $this->assertContains("3", $result);
48
        $this->assertNotContains("1", $result);
49
    }
50
}
51