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

InsertTest::testStatement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
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