SQLAnywhere16PlatformTest.php 2.25 KB
Newer Older
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
<?php

namespace Doctrine\Tests\DBAL\Platforms;

use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
use Doctrine\DBAL\Schema\Index;

class SQLAnywhere16PlatformTest extends SQLAnywhere12PlatformTest
{
    public function createPlatform()
    {
        return new SQLAnywhere16Platform;
    }

    public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
    {
        $this->assertEquals(
            'CREATE UNIQUE INDEX fooindex ON footable (a, b) WITH NULLS DISTINCT',
            $this->_platform->getCreateIndexSQL(
                new Index(
                    'fooindex',
                    array('a', 'b'),
                    true,
                    false,
                    array('with_nulls_distinct')
                ),
                'footable'
            )
        );

        // WITH NULLS DISTINCT clause not available on primary indexes.
        $this->assertEquals(
            'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
            $this->_platform->getCreateIndexSQL(
                new Index(
                    'fooindex',
                    array('a', 'b'),
                    false,
                    true,
                    array('with_nulls_distinct')
                ),
                'footable'
            )
        );

        // WITH NULLS DISTINCT clause not available on non-unique indexes.
        $this->assertEquals(
            'CREATE INDEX fooindex ON footable (a, b)',
            $this->_platform->getCreateIndexSQL(
                new Index(
                    'fooindex',
                    array('a', 'b'),
                    false,
                    false,
                    array('with_nulls_distinct')
                ),
                'footable'
            )
        );

        parent::testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL();
    }

    public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions()
    {
        $this->setExpectedException('UnexpectedValueException');

        $this->_platform->getCreateIndexSQL(
            new Index(
                'fooindex',
                array('a', 'b'),
                false,
                false,
                array('with_nulls_distinct', 'with_nulls_not_distinct')
            ),
            'footable'
        );
    }
}