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

DeckTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 47
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testAddAggregate() 0 5 1
A testEmpty() 0 7 1
A testAddRawAggregate() 0 5 1
A testConstructWithArrayAggregate() 0 4 1
A testConstructWithAlias() 0 4 1
A testToString() 0 4 1
A testConstructWithStringAggregate() 0 4 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use HexMakina\Crudites\Grammar\Deck;
5
6
7
8
class DeckTest extends TestCase
9
{
10
    public function testConstructWithStringAggregate()
11
    {
12
        $deck = new Deck('COUNT(*)');
13
        $this->assertEquals('COUNT(*)', (string)$deck);
14
    }
15
16
    public function testConstructWithArrayAggregate()
17
    {
18
        $deck = new Deck(['table', 'column']);
19
        $this->assertEquals('`table`.`column`', (string)$deck);
20
    }
21
22
    public function testConstructWithAlias()
23
    {
24
        $deck = new Deck('COUNT(*)', 'total');
25
        $this->assertEquals('COUNT(*) AS `total`', (string)$deck);
26
    }
27
28
    public function testAddAggregate()
29
    {
30
        $deck = new Deck('COUNT(*)');
31
        $deck->add('SUM(column)', 'sum_column');
32
        $this->assertEquals('COUNT(*),SUM(column) AS `sum_column`', (string)$deck);
33
    }
34
35
    public function testAddRawAggregate()
36
    {
37
        $deck = new Deck('COUNT(*)');
38
        $deck->addRaw('SUM(column) AS `sum_column`');
39
        $this->assertEquals('COUNT(*),SUM(column) AS `sum_column`', (string)$deck);
40
    }
41
42
    public function testToString()
43
    {
44
        $deck = new Deck('COUNT(*)');
45
        $this->assertEquals('COUNT(*)', (string)$deck);
46
    }
47
48
    public function testEmpty()
49
    {
50
        $deck = new Deck('');
51
        $this->assertTrue($deck->empty());
52
53
        $deck = new Deck('COUNT(*)');
54
        $this->assertFalse($deck->empty());
55
    }
56
}