DeleteTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSut() 0 3 1
A testDeleteComplex() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace QB\MySQL\Statement;
6
7
use QB\Generic\Expr\Expr;
8
use QB\Generic\Statement\DeleteTest as GenericDeleteTest;
9
10
class DeleteTest extends GenericDeleteTest
11
{
12
    public function testDeleteComplex()
13
    {
14
        $sql = (string)$this->getSut('foo')
15
            ->modifier(Delete::LOW_PRIORITY, Delete::QUICK, Delete::IGNORE)
16
            ->where('foo.bar = "foo-bar"', new Expr('bar.foo = ?', ['bar-foo']))
17
            ->orderBy('bar.baz', 'DESC')
18
            ->limit(10);
19
20
        $parts   = [];
21
        $parts[] = 'DELETE LOW_PRIORITY QUICK IGNORE FROM foo';
22
        $parts[] = 'WHERE foo.bar = "foo-bar" AND bar.foo = ?';
23
        $parts[] = 'ORDER BY bar.baz DESC';
24
        $parts[] = 'LIMIT 10';
25
26
        $expectedSql = implode(PHP_EOL, $parts);
27
28
        $this->assertSame($expectedSql, $sql);
29
    }
30
31
    /**
32
     * @param string ...$tables
33
     *
34
     * @return Delete
35
     */
36
    protected function getSut(string ...$tables): Delete
37
    {
38
        return (new Delete())->from(...$tables);
39
    }
40
}
41