File: PartitionDefinitionTest.php

package info (click to toggle)
phpmyadmin-sql-parser 5.10.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,244 kB
  • sloc: php: 52,958; makefile: 13; sh: 8
file content (36 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

declare(strict_types=1);

namespace PhpMyAdmin\SqlParser\Tests\Components;

use PhpMyAdmin\SqlParser\Components\PartitionDefinition;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Tests\TestCase;

class PartitionDefinitionTest extends TestCase
{
    public function testParse(): void
    {
        $component = PartitionDefinition::parse(
            new Parser(),
            $this->getTokensList('PARTITION p0 VALUES LESS THAN(1990)')
        );
        $this->assertFalse($component->isSubpartition);
        $this->assertEquals('p0', $component->name);
        $this->assertEquals('LESS THAN', $component->type);
        $this->assertEquals('(1990)', $component->expr->expr);
    }

    public function testParseNameWithUnderscore(): void
    {
        $component = PartitionDefinition::parse(
            new Parser(),
            $this->getTokensList('PARTITION 2017_12 VALUES LESS THAN (\'2018-01-01 00:00:00\') ENGINE = MyISAM')
        );
        $this->assertFalse($component->isSubpartition);
        $this->assertEquals('2017_12', $component->name);
        $this->assertEquals('LESS THAN', $component->type);
        $this->assertEquals('(\'2018-01-01 00:00:00\')', $component->expr->expr);
    }
}