Passed
Push — main ( d95b4b...96e631 )
by Sammy
01:51
created

InsertTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithEmptyData() 0 6 1
A testStatement() 0 7 1
A testConstructorWithValidData() 0 6 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use HexMakina\Crudites\Grammar\Query\Insert;
5
6
class InsertTest extends TestCase
7
{
8
    public function testConstructorWithEmptyData()
9
    {
10
        $this->expectException(\InvalidArgumentException::class);
11
        $this->expectExceptionMessage('EMPTY_DATA');
12
13
        new Insert('test_table', []);
14
    }
15
16
    public function testConstructorWithValidData()
17
    {
18
        $data = ['field1' => 'value1', 'field2' => 'value2'];
19
        $insert = new Insert('test_table', $data);
20
21
        $this->assertInstanceOf(Insert::class, $insert);
22
    }
23
24
    public function testStatement()
25
    {
26
        $data = ['field1' => 'value1', 'field2' => 'value2'];
27
        $insert = new Insert('test_table', $data);
28
29
        $expectedStatement = 'INSERT INTO `test_table` (`field1`, `field2`) VALUES (:test_table_field1, :test_table_field2)';
30
        $this->assertEquals($expectedStatement, $insert->statement());
31
    }
32
}
33