1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<?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\Types;
final class UniqueConstraintTest extends FunctionalTestCase
{
public function testUnnamedUniqueConstraint(): void
{
$this->dropTableIfExists('users');
$users = Table::editor()
->setUnquotedName('users')
->setColumns(
Column::editor()
->setUnquotedName('username')
->setTypeName(Types::STRING)
->setLength(32)
->create(),
Column::editor()
->setUnquotedName('email')
->setTypeName(Types::STRING)
->setLength(255)
->create(),
)
->setUniqueConstraints(
UniqueConstraint::editor()
->setUnquotedColumnNames('username')
->create(),
UniqueConstraint::editor()
->setUnquotedColumnNames('email')
->create(),
)
->create();
$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();
}
}
|