File: UniqueConstraintTest.php

package info (click to toggle)
php-doctrine-dbal 4.2.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 4,644 kB
  • sloc: php: 46,471; xml: 460; makefile: 22
file content (36 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download
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
<?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();
    }
}