-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathEnumColumnTest.php
More file actions
62 lines (52 loc) · 1.71 KB
/
EnumColumnTest.php
File metadata and controls
62 lines (52 loc) · 1.71 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Pgsql\Tests\Column;
use PHPUnit\Framework\Attributes\TestWith;
use Yiisoft\Db\Pgsql\Tests\Support\IntegrationTestTrait;
use Yiisoft\Db\Schema\Column\EnumColumn;
use Yiisoft\Db\Tests\Common\CommonEnumColumnTest;
final class EnumColumnTest extends CommonEnumColumnTest
{
use IntegrationTestTrait;
#[TestWith(['INTEGER CHECK (status IN (1, 2, 3))'])]
#[TestWith(["TEXT CHECK (status != 'abc')"])]
#[TestWith(["TEXT CHECK (status IN ('a', 'b') OR status = 'x')"])]
#[TestWith(["TEXT CHECK (status IN ('a', 'b') OR status IN ('x', 'y'))"])]
public function testNonEnumCheck(string $columnDefinition): void
{
$this->dropTable('test_enum_table');
$this->executeStatements(
<<<SQL
CREATE TABLE test_enum_table (
id INTEGER,
status $columnDefinition
)
SQL,
);
$db = $this->getSharedConnection();
$column = $db->getTableSchema('test_enum_table')->getColumn('status');
$this->assertNotInstanceOf(EnumColumn::class, $column);
$this->dropTable('test_enum_table');
}
protected function createDatabaseObjectsStatements(): array
{
return [
<<<SQL
CREATE TYPE enum_status AS ENUM ('active', 'unactive', 'pending')
SQL,
<<<SQL
CREATE TABLE tbl_enum (
id INTEGER,
status enum_status
)
SQL,
];
}
protected function dropDatabaseObjectsStatements(): array
{
return [
'DROP TABLE IF EXISTS tbl_enum',
'DROP TYPE IF EXISTS enum_status',
];
}
}