Passed
Push — main ( b49db2...9f0690 )
by Sammy
08:20
created

GroupByTest::testStringAddArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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