ReservedKeywordsValidatorTest.php 1.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php

namespace Doctrine\Tests\DBAL\Platforms;

use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator;
use Doctrine\DBAL\Schema\Table;

class ReservedKeywordsValidatorTest extends \Doctrine\Tests\DbalTestCase
{
    /**
     * @var ReservedKeywordsValidator
     */
    private $validator;
14

15
    protected function setUp()
16 17 18 19 20
    {
        $this->validator = new ReservedKeywordsValidator(array(
            new \Doctrine\DBAL\Platforms\Keywords\MySQLKeywords()
        ));
    }
21

22 23 24 25
    public function testReservedTableName()
    {
        $table = new Table("TABLE");
        $this->validator->acceptTable($table);
26

27
        self::assertEquals(
28 29 30 31
            array('Table TABLE keyword violations: MySQL'),
            $this->validator->getViolations()
        );
    }
32

33 34 35 36
    public function testReservedColumnName()
    {
        $table = new Table("TABLE");
        $column = $table->addColumn('table', 'string');
37

38
        $this->validator->acceptColumn($table, $column);
39

40
        self::assertEquals(
41 42 43 44
            array('Table TABLE column table keyword violations: MySQL'),
            $this->validator->getViolations()
        );
    }
45
}