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

DeckTest::testToString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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