DrizzleSchemaManagerTest.php 1.92 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\Tests\DBAL\Functional\Schema;

5 6
use Doctrine\DBAL\Schema\Table;

7 8
class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
Steve Müller's avatar
Steve Müller committed
9 10 11 12
    public function testListTableWithBinary()
    {
        $tableName = 'test_binary_table';

13
        $table = new Table($tableName);
Steve Müller's avatar
Steve Müller committed
14 15 16 17 18 19 20 21 22
        $table->addColumn('id', 'integer');
        $table->addColumn('column_varbinary', 'binary', array());
        $table->addColumn('column_binary', 'binary', array('fixed' => true));
        $table->setPrimaryKey(array('id'));

        $this->_sm->createTable($table);

        $table = $this->_sm->listTableDetails($tableName);

23 24
        self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_varbinary')->getType());
        self::assertFalse($table->getColumn('column_varbinary')->getFixed());
Steve Müller's avatar
Steve Müller committed
25

26 27
        self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_binary')->getType());
        self::assertFalse($table->getColumn('column_binary')->getFixed());
Steve Müller's avatar
Steve Müller committed
28
    }
29 30 31 32 33 34 35 36 37 38 39 40 41

    public function testColumnCollation()
    {
        $table = new Table('test_collation');
        $table->addOption('collate', $collation = 'utf8_unicode_ci');
        $table->addColumn('id', 'integer');
        $table->addColumn('text', 'text');
        $table->addColumn('foo', 'text')->setPlatformOption('collation', 'utf8_swedish_ci');
        $table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
        $this->_sm->dropAndCreateTable($table);

        $columns = $this->_sm->listTableColumns('test_collation');

42 43 44 45
        self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
        self::assertEquals('utf8_unicode_ci', $columns['text']->getPlatformOption('collation'));
        self::assertEquals('utf8_swedish_ci', $columns['foo']->getPlatformOption('collation'));
        self::assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
46
    }
Steve Müller's avatar
Steve Müller committed
47
}