CommandTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testToStringSimple() 0 9 1
A testGetParams() 0 16 1
A getSut() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace QB\Generic\Statement;
6
7
use PDO;
8
use PHPUnit\Framework\TestCase;
9
use QB\Generic\Clause\Column;
10
use QB\Generic\Expr\Expr;
11
12
class CommandTest extends TestCase
13
{
14
    public function testToStringSimple()
15
    {
16
        $command = 'BEGIN TRANSACTION';
17
18
        $query = new Command($command);
19
20
        $sql = (string)$query;
21
22
        $this->assertSame($command, $sql);
23
    }
24
25
    public function testGetParams()
26
    {
27
        $command = 'EXPLAIN %s';
28
29
        $query = (new Select())->columns(new Column(new Expr('?', [2])));
30
31
        $query = new Command($command, $query);
32
33
        $sql    = (string)$query;
34
        $params = $query->getParams();
35
36
        $expectedSql = 'EXPLAIN SELECT ?';
37
        $expectedParams = [[2, PDO::PARAM_INT]];
38
39
        $this->assertSame($expectedSql, $sql);
40
        $this->assertSame($expectedParams, $params);
41
    }
42
43
    /**
44
     * @param string ...$tables
45
     *
46
     * @return IDelete
47
     */
48
    protected function getSut(string ...$tables): IDelete
49
    {
50
        return (new Delete())->from(...$tables);
51
    }
52
}
53