Passed
Push — main ( 225a1c...d5eb66 )
by Peter
02:35
created

TruncateTest::testToStringSimple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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