-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathColumnFactoryTest.php
69 lines (55 loc) · 2.28 KB
/
ColumnFactoryTest.php
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
63
64
65
66
67
68
69
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Mysql\Tests;
use PHPUnit\Framework\Attributes\DataProviderExternal;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Mysql\Column\ColumnFactory;
use Yiisoft\Db\Mysql\Tests\Provider\ColumnFactoryProvider;
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Schema\Column\ColumnInterface;
use Yiisoft\Db\Tests\AbstractColumnFactoryTest;
/**
* @group mysql
*/
final class ColumnFactoryTest extends AbstractColumnFactoryTest
{
use TestTrait;
protected function getColumnFactoryClass(): string
{
return ColumnFactory::class;
}
#[DataProviderExternal(ColumnFactoryProvider::class, 'dbTypes')]
public function testFromDbType(string $dbType, string $expectedType, string $expectedInstanceOf): void
{
parent::testFromDbType($dbType, $expectedType, $expectedInstanceOf);
}
#[DataProviderExternal(ColumnFactoryProvider::class, 'definitions')]
public function testFromDefinition(string $definition, ColumnInterface $expected): void
{
parent::testFromDefinition($definition, $expected);
}
#[DataProviderExternal(ColumnFactoryProvider::class, 'pseudoTypes')]
public function testFromPseudoType(string $pseudoType, ColumnInterface $expected): void
{
parent::testFromPseudoType($pseudoType, $expected);
}
#[DataProviderExternal(ColumnFactoryProvider::class, 'types')]
public function testFromType(string $type, string $expectedType, string $expectedInstanceOf): void
{
parent::testFromType($type, $expectedType, $expectedInstanceOf);
}
#[DataProviderExternal(ColumnFactoryProvider::class, 'defaultValueRaw')]
public function testFromTypeDefaultValueRaw(string $type, string|null $defaultValueRaw, mixed $expected): void
{
parent::testFromTypeDefaultValueRaw($type, $defaultValueRaw, $expected);
}
public function testExpressionDefaultValueRaw(): void
{
$db = $this->getConnection();
$columnFactory = $db->getColumnFactory();
$column = $columnFactory->fromType(ColumnType::DATETIME, ['defaultValueRaw' => 'now()', 'extra' => 'DEFAULT_GENERATED']);
$this->assertEquals(new Expression('now()'), $column->getDefaultValue());
$db->close();
}
}