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

PartitionDefinitionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testParseNameWithUnderscore() 0 10 1
A testParse() 0 10 1
1
<?php
2
3
namespace PhpMyAdmin\SqlParser\Tests\Components;
4
5
use PhpMyAdmin\SqlParser\Components\PartitionDefinition;
6
use PhpMyAdmin\SqlParser\Parser;
7
use PhpMyAdmin\SqlParser\Tests\TestCase;
8
9
class PartitionDefinitionTest extends TestCase
10
{
11
    public function testParse()
12
    {
13
        $component = PartitionDefinition::parse(
14
            new Parser(),
15
            $this->getTokensList('PARTITION p0 VALUES LESS THAN(1990)')
16
        );
17
        $this->assertFalse($component->isSubpartition);
18
        $this->assertEquals('p0', $component->name);
19
        $this->assertEquals('LESS THAN', $component->type);
20
        $this->assertEquals('(1990)', $component->expr->expr);
21
    }
22
23
    public function testParseNameWithUnderscore()
24
    {
25
        $component = PartitionDefinition::parse(
26
            new Parser(),
27
            $this->getTokensList('PARTITION 2017_12 VALUES LESS THAN (\'2018-01-01 00:00:00\') ENGINE = MyISAM')
28
        );
29
        $this->assertFalse($component->isSubpartition);
30
        $this->assertEquals('2017_12', $component->name);
31
        $this->assertEquals('LESS THAN', $component->type);
32
        $this->assertEquals('(\'2018-01-01 00:00:00\')', $component->expr->expr);
33
    }
34
}
35