-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.10.x' into 2.11.x
- Loading branch information
Showing
5 changed files
with
124 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\DBAL\Functional\Schema; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Tests\DbalFunctionalTestCase; | ||
|
||
class ForeignKeyTest extends DbalFunctionalTestCase | ||
{ | ||
public function testCreatingATableWithAForeignKey() : void | ||
{ | ||
$schema = new Schema(); | ||
|
||
$referencedTable = $schema->createTable('referenced_table'); | ||
$referencedTable->addColumn('id', 'integer'); | ||
$referencedTable->setPrimaryKey(['id']); | ||
|
||
$referencingTable = $schema->createTable('referencing_table'); | ||
$referencingTable->addColumn('referenced_id', 'integer'); | ||
$referencingTable->addForeignKeyConstraint( | ||
$referencedTable, | ||
['referenced_id'], | ||
['id'] | ||
); | ||
|
||
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) { | ||
$this->connection->exec($sql); | ||
} | ||
|
||
self::assertCount( | ||
1, | ||
$this->connection->getSchemaManager()->listTableForeignKeys('referencing_table') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters