UpdateTest::testStatement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use HexMakina\Crudites\Grammar\Query\Update;
5
use HexMakina\Crudites\Grammar\Clause\Set;
6
use HexMakina\Crudites\Grammar\Clause\Where;
7
8
9
class UpdateTest extends TestCase
10
{
11
    public function testConstructorThrowsExceptionOnEmptyAlterations()
12
    {
13
        $this->expectException(\InvalidArgumentException::class);
14
        $this->expectExceptionMessage('EMPTY_ALTERATIONS_OR_CONDITIONS');
15
        
16
        new Update('test_table', [], ['id' => 1]);
17
    }
18
19
    public function testConstructorThrowsExceptionOnEmptyConditions()
20
    {
21
        $this->expectException(\InvalidArgumentException::class);
22
        $this->expectExceptionMessage('EMPTY_ALTERATIONS_OR_CONDITIONS');
23
        
24
        new Update('test_table', ['name' => 'test'], []);
25
    }
26
27
    public function testStatement()
28
    {
29
        $update = new Update('test_table', ['name' => 'test'], ['id' => 1]);
30
        $expectedStatement = "UPDATE `test_table` SET `name` = :set_name WHERE `test_table`.`id` = :andFields_test_table_id;";
31
        
32
        $this->assertEquals($expectedStatement, $update->statement());
33
    }
34
}