OrderByTest::testConstruct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use HexMakina\Crudites\Grammar\Clause\OrderBy;
5
6
class OrderByTest extends TestCase
7
{
8
    public function testConstruct()
9
    {
10
        $selected = 'column1';
11
        $direction = 'ASC';
12
        $orderBy = new OrderBy($selected, $direction);
13
14
        $this->assertInstanceOf(OrderBy::class, $orderBy);
15
        $this->assertEquals('ORDER BY column1 ASC', (string)$orderBy);
16
    }
17
18
    public function testAdd()
19
    {
20
        $selected1 = 'column1';
21
        $direction1 = 'ASC';
22
        $orderBy = new OrderBy($selected1, $direction1);
23
24
        $selected2 = 'column2';
25
        $direction2 = 'DESC';
26
        $orderBy->add($selected2, $direction2);
27
28
        $this->assertEquals('ORDER BY column1 ASC,column2 DESC', (string)$orderBy);
29
    }
30
31
    public function testName()
32
    {
33
        $orderBy = new OrderBy('column1', 'ASC');
34
        $this->assertEquals(OrderBy::ORDER, $orderBy->name());
35
    }
36
}