Commit 15a601a7 authored by Adrien Crivelli's avatar Adrien Crivelli

Cover Index options with unit tests

parent f650cfb5
...@@ -845,6 +845,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase ...@@ -845,6 +845,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
'ALTER TABLE mytable RENAME quoted3 TO "baz"', 'ALTER TABLE mytable RENAME quoted3 TO "baz"',
); );
} }
public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes() public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()
{ {
$this->markTestSkipped('Index declaration in statements like CREATE TABLE is not supported.'); $this->markTestSkipped('Index declaration in statements like CREATE TABLE is not supported.');
......
...@@ -8,9 +8,9 @@ use Doctrine\DBAL\Schema\Index; ...@@ -8,9 +8,9 @@ use Doctrine\DBAL\Schema\Index;
class IndexTest extends \PHPUnit_Framework_TestCase class IndexTest extends \PHPUnit_Framework_TestCase
{ {
public function createIndex($unique=false, $primary=false) public function createIndex($unique = false, $primary = false, $options = array())
{ {
return new Index("foo", array("bar", "baz"), $unique, $primary); return new Index("foo", array("bar", "baz"), $unique, $primary, array(), $options);
} }
public function testCreateIndex() public function testCreateIndex()
...@@ -142,4 +142,18 @@ class IndexTest extends \PHPUnit_Framework_TestCase ...@@ -142,4 +142,18 @@ class IndexTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($index->hasColumnAtPosition("bar", 1)); $this->assertFalse($index->hasColumnAtPosition("bar", 1));
$this->assertFalse($index->hasColumnAtPosition("baz", 0)); $this->assertFalse($index->hasColumnAtPosition("baz", 0));
} }
public function testOptions()
{
$idx1 = $this->createIndex();
$this->assertFalse($idx1->hasOption('where'));
$this->assertEmpty($idx1->getOptions());
$idx2 = $this->createIndex(false, false, array('where' => 'name IS NULL'));
$this->assertTrue($idx2->hasOption('where'));
$this->assertTrue($idx2->hasOption('WHERE'));
$this->assertSame('name IS NULL', $idx2->getOption('where'));
$this->assertSame('name IS NULL', $idx2->getOption('WHERE'));
$this->assertSame(array('where' => 'name IS NULL'), $idx2->getOptions());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment