Passed
Pull Request — master (#311)
by William
12:43
created

StatementTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBuilder() 0 24 1
1
<?php
2
3
namespace PhpMyAdmin\SqlParser\Tests\Builder;
4
5
use PhpMyAdmin\SqlParser\Components\Condition;
6
use PhpMyAdmin\SqlParser\Components\Expression;
7
use PhpMyAdmin\SqlParser\Components\Limit;
8
use PhpMyAdmin\SqlParser\Components\OptionsArray;
9
use PhpMyAdmin\SqlParser\Statements\SelectStatement;
10
use PhpMyAdmin\SqlParser\Tests\TestCase;
11
12
class StatementTest extends TestCase
13
{
14
    public function testBuilder()
15
    {
16
        $stmt = new SelectStatement();
17
18
        $stmt->options = new OptionsArray(array('DISTINCT'));
19
20
        $stmt->expr[] = new Expression('sakila', 'film', 'film_id', 'fid');
21
        $stmt->expr[] = new Expression('COUNT(film_id)');
22
23
        $stmt->from[] = new Expression('', 'film', '');
24
        $stmt->from[] = new Expression('', 'actor', '');
25
26
        $stmt->where[] = new Condition('film_id > 10');
27
        $stmt->where[] = new Condition('OR');
28
        $stmt->where[] = new Condition('actor.age > 25');
29
30
        $stmt->limit = new Limit(1, 10);
31
32
        $this->assertEquals(
33
            'SELECT DISTINCT `sakila`.`film`.`film_id` AS `fid`, COUNT(film_id) ' .
34
            'FROM `film`, `actor` ' .
35
            'WHERE film_id > 10 OR actor.age > 25 ' .
36
            'LIMIT 10, 1',
37
            (string) $stmt
38
        );
39
    }
40
}
41