UpdateTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testStatement() 0 6 1
A testConstructorThrowsExceptionOnEmptyConditions() 0 6 1
A testConstructorThrowsExceptionOnEmptyAlterations() 0 6 1
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
}