ReservedKeywordsValidatorTest.php 1.11 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 16 17 18 19 20
    public function setUp()
    {
        $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 28 29 30 31
        $this->assertEquals(
            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 41 42 43 44 45
        $this->assertEquals(
            array('Table TABLE column table keyword violations: MySQL'),
            $this->validator->getViolations()
        );
    }
}