OrderByTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 29
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testName() 0 4 1
A testConstruct() 0 8 1
A testAdd() 0 11 1
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
}