public function testCreateTableWithForeignKeys()
{
if(!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Platform does not support foreign keys.');
}
$tableB = $this->getTestTable('test_foreign');
$this->_sm->dropAndCreateTable($tableB);
$tableA = $this->getTestTable('test_create_fk');
$tableA->addForeignKeyConstraint('test_foreign', array('foreign_key_test'), array('id'));
$this->_sm->dropAndCreateTable($tableA);
$fkTable = $this->_sm->listTableDetails('test_create_fk');
$fkConstraints = $fkTable->getForeignKeys();
$this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key.");
$fkConstraint = current($fkConstraints);
$this->assertType('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint);
$this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName()));
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns()));
$this->assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), "The columns of a foreign key constraint should always be indexed.");
}