GroupByTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testAddString() 0 6 1
A testConstructArray() 0 5 1
A testConstructString() 0 5 1
A testName() 0 5 1
A testAddArray() 0 6 1
A testStringAddArray() 0 6 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use HexMakina\Crudites\Grammar\Clause\GroupBy;
5
6
class GroupByTest extends TestCase
7
{
8
    public function testName()
9
    {
10
        $selected = 'column1';
11
        $groupBy = new GroupBy($selected);
12
        $this->assertEquals(GroupBy::GROUP, $groupBy->name());
13
    }
14
15
    public function testConstructString()
16
    {
17
        $selected = 'column1';
18
        $groupBy = new GroupBy($selected);
19
        $this->assertEquals('GROUP BY column1', (string)$groupBy);
20
    }
21
22
    public function testConstructArray()
23
    {
24
        $selected = ['table', 'column'];
25
        $groupBy = new GroupBy($selected);
26
        $this->assertEquals('GROUP BY `table`.`column`', (string)$groupBy);
27
    }
28
29
    public function testAddString()
30
    {
31
        $selected = 'column1';
32
        $groupBy = new GroupBy($selected);
33
        $groupBy->add('column2');
34
        $this->assertEquals('GROUP BY column1,column2', (string)$groupBy);
35
    }
36
37
    public function testAddArray()
38
    {
39
        $selected = ['table', 'column'];
40
        $groupBy = new GroupBy($selected);
41
        $groupBy->add(['table', 'column2']);
42
        $this->assertEquals('GROUP BY `table`.`column`,`table`.`column2`', (string)$groupBy);
43
    }
44
45
    public function testStringAddArray()
46
    {
47
        $selected = 'column';
48
        $groupBy = new GroupBy($selected);
49
        $groupBy->add(['table', 'column2']);
50
        $this->assertEquals('GROUP BY column,`table`.`column2`', (string)$groupBy);
51
    }
52
}
53