1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Tests\Migration; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use Yiisoft\Db\Tests\Support\TestTrait; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @group db |
12
|
|
|
* |
13
|
|
|
* @psalm-suppress PropertyNotSetInConstructor |
14
|
|
|
*/ |
15
|
|
|
final class MigrationBuilderTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
use TestTrait; |
18
|
|
|
|
19
|
|
|
public function testBigInteger(): void |
20
|
|
|
{ |
21
|
|
|
$db = $this->getConnection(); |
22
|
|
|
|
23
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
24
|
|
|
|
25
|
|
|
$this->assertSame('bigint', (string) $migrationBuilder->bigInteger()); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testBigPrimaryKey(): void |
29
|
|
|
{ |
30
|
|
|
$db = $this->getConnection(); |
31
|
|
|
|
32
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
33
|
|
|
|
34
|
|
|
$this->assertSame('bigpk', (string) $migrationBuilder->bigPrimaryKey()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testBinary(): void |
38
|
|
|
{ |
39
|
|
|
$db = $this->getConnection(); |
40
|
|
|
|
41
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
42
|
|
|
|
43
|
|
|
$this->assertSame('binary', (string) $migrationBuilder->binary()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testBoolean(): void |
47
|
|
|
{ |
48
|
|
|
$db = $this->getConnection(); |
49
|
|
|
|
50
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
51
|
|
|
|
52
|
|
|
$this->assertSame('boolean', (string) $migrationBuilder->boolean()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testChar(): void |
56
|
|
|
{ |
57
|
|
|
$db = $this->getConnection(); |
58
|
|
|
|
59
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
60
|
|
|
|
61
|
|
|
$this->assertSame('char', (string) $migrationBuilder->char()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testDate(): void |
65
|
|
|
{ |
66
|
|
|
$db = $this->getConnection(); |
67
|
|
|
|
68
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
69
|
|
|
|
70
|
|
|
$this->assertSame('date', (string) $migrationBuilder->date()); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function testDateTime(): void |
74
|
|
|
{ |
75
|
|
|
$db = $this->getConnection(); |
76
|
|
|
|
77
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
78
|
|
|
|
79
|
|
|
$this->assertSame('datetime', (string) $migrationBuilder->dateTime()); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function testDecimal(): void |
83
|
|
|
{ |
84
|
|
|
$db = $this->getConnection(); |
85
|
|
|
|
86
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
87
|
|
|
|
88
|
|
|
$this->assertSame('decimal', (string) $migrationBuilder->decimal()); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function testDouble(): void |
92
|
|
|
{ |
93
|
|
|
$db = $this->getConnection(); |
94
|
|
|
|
95
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
96
|
|
|
|
97
|
|
|
$this->assertSame('double', (string) $migrationBuilder->double()); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function testFloat(): void |
101
|
|
|
{ |
102
|
|
|
$db = $this->getConnection(); |
103
|
|
|
|
104
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
105
|
|
|
|
106
|
|
|
$this->assertSame('float', (string) $migrationBuilder->float()); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function testInteger(): void |
110
|
|
|
{ |
111
|
|
|
$db = $this->getConnection(); |
112
|
|
|
|
113
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
114
|
|
|
|
115
|
|
|
$this->assertSame('integer', (string) $migrationBuilder->integer()); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function testJson(): void |
119
|
|
|
{ |
120
|
|
|
$db = $this->getConnection(); |
121
|
|
|
|
122
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
123
|
|
|
|
124
|
|
|
$this->assertSame('json', (string) $migrationBuilder->json()); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function testMoney(): void |
128
|
|
|
{ |
129
|
|
|
$db = $this->getConnection(); |
130
|
|
|
|
131
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
132
|
|
|
|
133
|
|
|
$this->assertSame('money', (string) $migrationBuilder->money()); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function testPrimaryKey(): void |
137
|
|
|
{ |
138
|
|
|
$db = $this->getConnection(); |
139
|
|
|
|
140
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
141
|
|
|
|
142
|
|
|
$this->assertSame('pk', (string) $migrationBuilder->primaryKey()); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function testSmallInteger(): void |
146
|
|
|
{ |
147
|
|
|
$db = $this->getConnection(); |
148
|
|
|
|
149
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
150
|
|
|
|
151
|
|
|
$this->assertSame('smallint', (string) $migrationBuilder->smallInteger()); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function testString(): void |
155
|
|
|
{ |
156
|
|
|
$db = $this->getConnection(); |
157
|
|
|
|
158
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
159
|
|
|
|
160
|
|
|
$this->assertSame('string', (string) $migrationBuilder->string()); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function testText(): void |
164
|
|
|
{ |
165
|
|
|
$db = $this->getConnection(); |
166
|
|
|
|
167
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
168
|
|
|
|
169
|
|
|
$this->assertSame('text', (string) $migrationBuilder->text()); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function testTime(): void |
173
|
|
|
{ |
174
|
|
|
$db = $this->getConnection(); |
175
|
|
|
|
176
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
177
|
|
|
|
178
|
|
|
$this->assertSame('time', (string) $migrationBuilder->time()); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function testTimestamp(): void |
182
|
|
|
{ |
183
|
|
|
$db = $this->getConnection(); |
184
|
|
|
|
185
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
186
|
|
|
|
187
|
|
|
$this->assertSame('timestamp', (string) $migrationBuilder->timestamp()); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function testTinyInteger(): void |
191
|
|
|
{ |
192
|
|
|
$db = $this->getConnection(); |
193
|
|
|
|
194
|
|
|
$migrationBuilder = $db->getMigrationBuilder(); |
195
|
|
|
|
196
|
|
|
$this->assertSame('tinyint', (string) $migrationBuilder->tinyInteger()); |
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|