Passed
Push — main ( 0c2f80...877d81 )
by Peter
02:47
created

CommandTest::getSut()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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())->addColumns(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())->addFrom(...$tables);
51
    }
52
}
53