forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
153 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
name: "Website config validation" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "*.x" | ||
paths: | ||
- ".doctrine-project.json" | ||
- ".github/workflows/website-schema.yml" | ||
push: | ||
branches: | ||
- "*.x" | ||
paths: | ||
- ".doctrine-project.json" | ||
- ".github/workflows/website-schema.yml" | ||
|
||
jobs: | ||
json-validate: | ||
name: "Validate JSON schema" | ||
uses: "doctrine/.github/.github/workflows/[email protected]" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Schema; | ||
|
||
use Doctrine\DBAL\Schema\Column; | ||
use Doctrine\DBAL\Schema\ForeignKeyConstraint; | ||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\DBAL\Types\Types; | ||
|
||
final class ForeignKeyConstraintTest extends FunctionalTestCase | ||
{ | ||
public function testUnnamedForeignKeyConstraint(): void | ||
{ | ||
$this->dropTableIfExists('users'); | ||
$this->dropTableIfExists('roles'); | ||
$this->dropTableIfExists('teams'); | ||
|
||
$roles = new Table('roles'); | ||
$roles->addColumn('id', Types::INTEGER); | ||
$roles->setPrimaryKey(['id']); | ||
|
||
$teams = new Table('teams'); | ||
$teams->addColumn('id', Types::INTEGER); | ||
$teams->setPrimaryKey(['id']); | ||
|
||
$users = new Table('users', [ | ||
new Column('id', Type::getType(Types::INTEGER)), | ||
new Column('role_id', Type::getType(Types::INTEGER)), | ||
new Column('team_id', Type::getType(Types::INTEGER)), | ||
], [], [], [ | ||
new ForeignKeyConstraint(['role_id'], 'roles', ['id']), | ||
new ForeignKeyConstraint(['team_id'], 'teams', ['id']), | ||
]); | ||
$users->setPrimaryKey(['id']); | ||
|
||
$sm = $this->connection->createSchemaManager(); | ||
$sm->createTable($roles); | ||
$sm->createTable($teams); | ||
$sm->createTable($users); | ||
|
||
$table = $sm->introspectTable('users'); | ||
|
||
self::assertCount(2, $table->getForeignKeys()); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Schema; | ||
|
||
use Doctrine\DBAL\Schema\Column; | ||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Schema\UniqueConstraint; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\DBAL\Types\Types; | ||
|
||
final class UniqueConstraintTest extends FunctionalTestCase | ||
{ | ||
public function testUnnamedUniqueConstraint(): void | ||
{ | ||
$this->dropTableIfExists('users'); | ||
|
||
$users = new Table('users', [ | ||
new Column('id', Type::getType(Types::INTEGER)), | ||
new Column('username', Type::getType(Types::STRING), ['length' => 32]), | ||
new Column('email', Type::getType(Types::STRING), ['length' => 255]), | ||
], [], [ | ||
new UniqueConstraint('', ['username']), | ||
new UniqueConstraint('', ['email']), | ||
], []); | ||
|
||
$sm = $this->connection->createSchemaManager(); | ||
$sm->createTable($users); | ||
|
||
// we want to assert that the two empty names don't clash, but introspection of unique constraints is currently | ||
// not supported. for now, we just assert that the table can be created without exceptions. | ||
$this->expectNotToPerformAssertions(); | ||
} | ||
} |
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