Commit e65517e0 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #242 from Ocramius/hotfix/DBAL-370

Restore SqlitePlatform#supportsForeignKeyConstraints (no lies!)
parents 31bd1538 35305949
...@@ -602,6 +602,14 @@ class SqlitePlatform extends AbstractPlatform ...@@ -602,6 +602,14 @@ class SqlitePlatform extends AbstractPlatform
return true; return true;
} }
/**
* {@inheritDoc}
*/
public function supportsForeignKeyConstraints()
{
return false;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -433,13 +433,15 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -433,13 +433,15 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
// dont check for index size here, some platforms automatically add indexes for foreign keys. // dont check for index size here, some platforms automatically add indexes for foreign keys.
$this->assertFalse($table->hasIndex('foo_idx')); $this->assertFalse($table->hasIndex('foo_idx'));
$this->assertEquals(1, count($table->getForeignKeys())); if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$fks = $table->getForeignKeys(); $fks = $table->getForeignKeys();
$this->assertCount(1, $fks);
$foreignKey = current($fks); $foreignKey = current($fks);
$this->assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName())); $this->assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName()));
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns())); $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns())); $this->assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns()));
} }
}
public function testCreateAndListViews() public function testCreateAndListViews()
{ {
......
...@@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\TableDiff; ...@@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\TableDiff;
abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{ {
/** /**
* @var Doctrine\DBAL\Platforms\AbstractPlatform * @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/ */
protected $_platform; protected $_platform;
...@@ -156,6 +156,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -156,6 +156,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql); $this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql);
} }
public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys()
{
$fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
if ($this->_platform->supportsForeignKeyConstraints()) {
$this->assertInternalType(
'string',
$this->_platform->getCreateForeignKeySQL($fk, 'test')
);
} else {
$this->setExpectedException('Doctrine\DBAL\DBALException');
$this->_platform->getCreateForeignKeySQL($fk, 'test');
}
}
protected function getBitAndComparisonExpressionSql($value1, $value2) protected function getBitAndComparisonExpressionSql($value1, $value2)
{ {
return '(' . $value1 . ' & ' . $value2 . ')'; return '(' . $value1 . ' & ' . $value2 . ')';
......
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