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

namespace Doctrine\Tests\DBAL\Functional\Schema;

5 6
use Doctrine\DBAL\Schema\Table;

7 8 9 10
require_once __DIR__ . '/../../../TestInit.php';

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

15
        $table = new Table($tableName);
Steve Müller's avatar
Steve Müller committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
        $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);

        $this->assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_varbinary')->getType());
        $this->assertFalse($table->getColumn('column_varbinary')->getFixed());

        $this->assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_binary')->getType());
        $this->assertFalse($table->getColumn('column_binary')->getFixed());
    }
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

    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');

        $this->assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
        $this->assertEquals('utf8_unicode_ci', $columns['text']->getPlatformOption('collation'));
        $this->assertEquals('utf8_swedish_ci', $columns['foo']->getPlatformOption('collation'));
        $this->assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
    }
Steve Müller's avatar
Steve Müller committed
49
}