Passed
Pull Request — master (#377)
by Alexander
03:29 queued 56s
created

AbstractQueryBuilderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 22
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBuild() 0 20 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Db\Expression\ExpressionInterface;
9
use Yiisoft\Db\Tests\Support\DbHelper;
10
11
abstract class AbstractQueryBuilderTest extends TestCase
12
{
13
    public function testBuild(
14
        array|ExpressionInterface|string $conditions,
15
        string $expected,
16
        array $expectedParams = []
17
    ): void {
18
        $query = $this->mock->query()->where($conditions);
19
        [$sql, $params] = $this->mock
20
            ->queryBuilder($this->columnQuoteCharacter, $this->tableQuoteCharacter)
21
            ->build($query);
22
23
        $this->assertSame(
24
            'SELECT *' . (
25
                empty($expected) ? '' : ' WHERE ' . DbHelper::replaceQuotes(
26
                    $expected,
27
                    $this->mock->getDriverName(),
28
                )
29
            ),
30
            $sql,
31
        );
32
        $this->assertSame($expectedParams, $params);
33
    }
34
}
35