testToStringThrowsAnExceptionIfNotInitialized()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace QB\Generic\Statement;
6
7
use PHPUnit\Framework\TestCase;
8
use RuntimeException;
9
10
class TruncateTest extends TestCase
11
{
12
    /**
13
     * @suppress PhanNoopCast
14
     */
15
    public function testToStringThrowsAnExceptionIfNotInitialized()
16
    {
17
        $this->expectException(RuntimeException::class);
18
19
        (string)$this->getSut();
20
    }
21
22
    public function testToStringSimple()
23
    {
24
        $sql = (string)$this->getSut('foo', 'bar');
25
26
        $parts   = [];
27
        $parts[] = 'TRUNCATE foo, bar';
28
29
        $expectedSql = implode(PHP_EOL, $parts);
30
31
        $this->assertSame($expectedSql, $sql);
32
    }
33
34
    public function testGetParams()
35
    {
36
        $query = $this->getSut('foo', 'bar');
37
38
        $params = $query->getParams();
39
40
        $this->assertSame([], $params);
41
    }
42
43
    /**
44
     * @param string ...$tables
45
     *
46
     * @return ITruncate
47
     */
48
    protected function getSut(string ...$tables): ITruncate
49
    {
50
        return (new Truncate())->from(...$tables);
51
    }
52
}
53