Total Complexity | 63 |
Total Lines | 773 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like SqlitePlatformTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SqlitePlatformTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
13 | class SqlitePlatformTest extends AbstractPlatformTestCase |
||
14 | { |
||
15 | public function createPlatform() |
||
16 | { |
||
17 | return new SqlitePlatform; |
||
18 | } |
||
19 | |||
20 | public function getGenerateTableSql() |
||
21 | { |
||
22 | return 'CREATE TABLE test (id INTEGER NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; |
||
23 | } |
||
24 | |||
25 | public function getGenerateTableWithMultiColumnUniqueIndexSql() |
||
26 | { |
||
27 | return array( |
||
28 | 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', |
||
29 | 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)', |
||
30 | ); |
||
31 | } |
||
32 | |||
33 | public function testGeneratesSqlSnippets() |
||
34 | { |
||
35 | self::assertEquals('REGEXP', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); |
||
36 | self::assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); |
||
37 | self::assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); |
||
38 | } |
||
39 | |||
40 | public function testGeneratesTransactionCommands() |
||
41 | { |
||
42 | self::assertEquals( |
||
43 | 'PRAGMA read_uncommitted = 0', |
||
44 | $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED) |
||
45 | ); |
||
46 | self::assertEquals( |
||
47 | 'PRAGMA read_uncommitted = 1', |
||
48 | $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED) |
||
49 | ); |
||
50 | self::assertEquals( |
||
51 | 'PRAGMA read_uncommitted = 1', |
||
52 | $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ) |
||
53 | ); |
||
54 | self::assertEquals( |
||
55 | 'PRAGMA read_uncommitted = 1', |
||
56 | $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE) |
||
57 | ); |
||
58 | } |
||
59 | |||
60 | public function testPrefersIdentityColumns() |
||
61 | { |
||
62 | self::assertTrue($this->_platform->prefersIdentityColumns()); |
||
63 | } |
||
64 | |||
65 | public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers() |
||
66 | { |
||
67 | self::assertSame( |
||
68 | 'INTEGER', |
||
69 | $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true)) |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @group DBAL-752 |
||
75 | * @group DBAL-924 |
||
76 | */ |
||
77 | public function testGeneratesTypeDeclarationForTinyIntegers() |
||
78 | { |
||
79 | self::assertEquals( |
||
80 | 'TINYINT', |
||
81 | $this->_platform->getTinyIntTypeDeclarationSQL(array()) |
||
|
|||
82 | ); |
||
83 | self::assertEquals( |
||
84 | 'INTEGER', |
||
85 | $this->_platform->getTinyIntTypeDeclarationSQL(array('autoincrement' => true)) |
||
86 | ); |
||
87 | self::assertEquals( |
||
88 | 'INTEGER', |
||
89 | $this->_platform->getTinyIntTypeDeclarationSQL( |
||
90 | array('autoincrement' => true, 'primary' => true)) |
||
91 | ); |
||
92 | self::assertEquals( |
||
93 | 'TINYINT', |
||
94 | $this->_platform->getTinyIntTypeDeclarationSQL(array('unsigned' => false)) |
||
95 | ); |
||
96 | self::assertEquals( |
||
97 | 'TINYINT UNSIGNED', |
||
98 | $this->_platform->getTinyIntTypeDeclarationSQL(array('unsigned' => true)) |
||
99 | ); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @group DBAL-752 |
||
104 | * @group DBAL-924 |
||
105 | */ |
||
106 | public function testGeneratesTypeDeclarationForSmallIntegers() |
||
107 | { |
||
108 | self::assertEquals( |
||
109 | 'SMALLINT', |
||
110 | $this->_platform->getSmallIntTypeDeclarationSQL(array()) |
||
111 | ); |
||
112 | self::assertEquals( |
||
113 | 'INTEGER', |
||
114 | $this->_platform->getSmallIntTypeDeclarationSQL(array('autoincrement' => true)) |
||
115 | ); |
||
116 | self::assertEquals( |
||
117 | 'INTEGER', |
||
118 | $this->_platform->getTinyIntTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true)) |
||
119 | ); |
||
120 | self::assertEquals( |
||
121 | 'INTEGER', |
||
122 | $this->_platform->getSmallIntTypeDeclarationSQL( |
||
123 | array('autoincrement' => true, 'primary' => true)) |
||
124 | ); |
||
125 | self::assertEquals( |
||
126 | 'SMALLINT', |
||
127 | $this->_platform->getSmallIntTypeDeclarationSQL(array('unsigned' => false)) |
||
128 | ); |
||
129 | self::assertEquals( |
||
130 | 'SMALLINT UNSIGNED', |
||
131 | $this->_platform->getSmallIntTypeDeclarationSQL(array('unsigned' => true)) |
||
132 | ); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @group DBAL-752 |
||
137 | * @group DBAL-924 |
||
138 | */ |
||
139 | public function testGeneratesTypeDeclarationForMediumIntegers() |
||
140 | { |
||
141 | self::assertEquals( |
||
142 | 'MEDIUMINT', |
||
143 | $this->_platform->getMediumIntTypeDeclarationSQL(array()) |
||
144 | ); |
||
145 | self::assertEquals( |
||
146 | 'INTEGER', |
||
147 | $this->_platform->getMediumIntTypeDeclarationSQL(array('autoincrement' => true)) |
||
148 | ); |
||
149 | self::assertEquals( |
||
150 | 'INTEGER', |
||
151 | $this->_platform->getMediumIntTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true)) |
||
152 | ); |
||
153 | self::assertEquals( |
||
154 | 'INTEGER', |
||
155 | $this->_platform->getMediumIntTypeDeclarationSQL( |
||
156 | array('autoincrement' => true, 'primary' => true)) |
||
157 | ); |
||
158 | self::assertEquals( |
||
159 | 'MEDIUMINT', |
||
160 | $this->_platform->getMediumIntTypeDeclarationSQL(array('unsigned' => false)) |
||
161 | ); |
||
162 | self::assertEquals( |
||
163 | 'MEDIUMINT UNSIGNED', |
||
164 | $this->_platform->getMediumIntTypeDeclarationSQL(array('unsigned' => true)) |
||
165 | ); |
||
166 | } |
||
167 | |||
168 | public function testGeneratesTypeDeclarationForIntegers() |
||
169 | { |
||
170 | self::assertEquals( |
||
171 | 'INTEGER', |
||
172 | $this->_platform->getIntegerTypeDeclarationSQL(array()) |
||
173 | ); |
||
174 | self::assertEquals( |
||
175 | 'INTEGER', |
||
176 | $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)) |
||
177 | ); |
||
178 | self::assertEquals( |
||
179 | 'INTEGER', |
||
180 | $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true)) |
||
181 | ); |
||
182 | self::assertEquals( |
||
183 | 'INTEGER', |
||
184 | $this->_platform->getIntegerTypeDeclarationSQL( |
||
185 | array('autoincrement' => true, 'primary' => true)) |
||
186 | ); |
||
187 | self::assertEquals( |
||
188 | 'INTEGER', |
||
189 | $this->_platform->getIntegerTypeDeclarationSQL(array('unsigned' => false)) |
||
190 | ); |
||
191 | self::assertEquals( |
||
192 | 'INTEGER UNSIGNED', |
||
193 | $this->_platform->getIntegerTypeDeclarationSQL(array('unsigned' => true)) |
||
194 | ); |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @group DBAL-752 |
||
199 | * @group DBAL-924 |
||
200 | */ |
||
201 | public function testGeneratesTypeDeclarationForBigIntegers() |
||
202 | { |
||
203 | self::assertEquals( |
||
204 | 'BIGINT', |
||
205 | $this->_platform->getBigIntTypeDeclarationSQL(array()) |
||
206 | ); |
||
207 | self::assertEquals( |
||
208 | 'INTEGER', |
||
209 | $this->_platform->getBigIntTypeDeclarationSQL(array('autoincrement' => true)) |
||
210 | ); |
||
211 | self::assertEquals( |
||
212 | 'INTEGER', |
||
213 | $this->_platform->getBigIntTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true)) |
||
214 | ); |
||
215 | self::assertEquals( |
||
216 | 'INTEGER', |
||
217 | $this->_platform->getBigIntTypeDeclarationSQL( |
||
218 | array('autoincrement' => true, 'primary' => true)) |
||
219 | ); |
||
220 | self::assertEquals( |
||
221 | 'BIGINT', |
||
222 | $this->_platform->getBigIntTypeDeclarationSQL(array('unsigned' => false)) |
||
223 | ); |
||
224 | self::assertEquals( |
||
225 | 'BIGINT UNSIGNED', |
||
226 | $this->_platform->getBigIntTypeDeclarationSQL(array('unsigned' => true)) |
||
227 | ); |
||
228 | } |
||
229 | |||
230 | public function testGeneratesTypeDeclarationForStrings() |
||
231 | { |
||
232 | self::assertEquals( |
||
233 | 'CHAR(10)', |
||
234 | $this->_platform->getVarcharTypeDeclarationSQL( |
||
235 | array('length' => 10, 'fixed' => true)) |
||
236 | ); |
||
237 | self::assertEquals( |
||
238 | 'VARCHAR(50)', |
||
239 | $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), |
||
240 | 'Variable string declaration is not correct' |
||
241 | ); |
||
242 | self::assertEquals( |
||
243 | 'VARCHAR(255)', |
||
244 | $this->_platform->getVarcharTypeDeclarationSQL(array()), |
||
245 | 'Long string declaration is not correct' |
||
246 | ); |
||
247 | } |
||
248 | |||
249 | public function getGenerateIndexSql() |
||
250 | { |
||
251 | return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; |
||
252 | } |
||
253 | |||
254 | public function getGenerateUniqueIndexSql() |
||
255 | { |
||
256 | return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @expectedException \Doctrine\DBAL\DBALException |
||
261 | */ |
||
262 | public function testGeneratesForeignKeyCreationSql() |
||
263 | { |
||
264 | parent::testGeneratesForeignKeyCreationSql(); |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * @expectedException \Doctrine\DBAL\DBALException |
||
269 | */ |
||
270 | public function testGeneratesConstraintCreationSql() |
||
271 | { |
||
272 | parent::testGeneratesConstraintCreationSql(); |
||
273 | } |
||
274 | |||
275 | public function getGenerateForeignKeySql() |
||
276 | { |
||
277 | return null; |
||
278 | } |
||
279 | |||
280 | public function testModifyLimitQuery() |
||
281 | { |
||
282 | $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); |
||
283 | self::assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); |
||
284 | } |
||
285 | |||
286 | public function testModifyLimitQueryWithEmptyOffset() |
||
287 | { |
||
288 | $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); |
||
289 | self::assertEquals('SELECT * FROM user LIMIT 10', $sql); |
||
290 | } |
||
291 | |||
292 | public function testModifyLimitQueryWithOffsetAndEmptyLimit() |
||
293 | { |
||
294 | $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', null, 10); |
||
295 | self::assertEquals('SELECT * FROM user LIMIT -1 OFFSET 10', $sql); |
||
296 | } |
||
297 | |||
298 | public function getGenerateAlterTableSql() |
||
299 | { |
||
300 | return array( |
||
301 | "CREATE TEMPORARY TABLE __temp__mytable AS SELECT id, bar, bloo FROM mytable", |
||
302 | "DROP TABLE mytable", |
||
303 | "CREATE TABLE mytable (id INTEGER NOT NULL, baz VARCHAR(255) DEFAULT 'def' NOT NULL, bloo BOOLEAN DEFAULT '0' NOT NULL, quota INTEGER DEFAULT NULL, PRIMARY KEY(id))", |
||
304 | "INSERT INTO mytable (id, baz, bloo) SELECT id, bar, bloo FROM __temp__mytable", |
||
305 | "DROP TABLE __temp__mytable", |
||
306 | "ALTER TABLE mytable RENAME TO userlist", |
||
307 | ); |
||
308 | } |
||
309 | |||
310 | /** |
||
311 | * @group DDC-1845 |
||
312 | */ |
||
313 | public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() |
||
314 | { |
||
315 | $table = new \Doctrine\DBAL\Schema\Table('test'); |
||
316 | $table->addColumn('"like"', 'integer', array('notnull' => true, 'autoincrement' => true)); |
||
317 | $table->setPrimaryKey(array('"like"')); |
||
318 | |||
319 | $createTableSQL = $this->_platform->getCreateTableSQL($table); |
||
320 | self::assertEquals( |
||
321 | 'CREATE TABLE test ("like" INTEGER NOT NULL, PRIMARY KEY("like"))', |
||
322 | $createTableSQL[0] |
||
323 | ); |
||
324 | } |
||
325 | |||
326 | public function testAlterTableAddColumns() |
||
327 | { |
||
328 | $diff = new TableDiff('user'); |
||
329 | $diff->addedColumns['foo'] = new Column('foo', Type::getType('string')); |
||
330 | $diff->addedColumns['count'] = new Column('count', Type::getType('integer'), array('notnull' => false, 'default' => 1)); |
||
331 | |||
332 | $expected = array( |
||
333 | 'ALTER TABLE user ADD COLUMN foo VARCHAR(255) NOT NULL', |
||
334 | 'ALTER TABLE user ADD COLUMN count INTEGER DEFAULT 1', |
||
335 | ); |
||
336 | |||
337 | self::assertEquals($expected, $this->_platform->getAlterTableSQL($diff)); |
||
338 | } |
||
339 | |||
340 | /** |
||
341 | * @dataProvider complexDiffProvider |
||
342 | */ |
||
343 | public function testAlterTableAddComplexColumns(TableDiff $diff) : void |
||
344 | { |
||
345 | $this->expectException(DBALException::class); |
||
346 | |||
347 | $this->_platform->getAlterTableSQL($diff); |
||
348 | } |
||
349 | |||
350 | public function complexDiffProvider() : array |
||
351 | { |
||
352 | $date = new TableDiff('user'); |
||
353 | $date->addedColumns['time'] = new Column('time', Type::getType('date'), array('default' => 'CURRENT_DATE')); |
||
354 | |||
355 | |||
356 | $id = new TableDiff('user'); |
||
357 | $id->addedColumns['id'] = new Column('id', Type::getType('integer'), array('autoincrement' => true)); |
||
358 | |||
359 | return [ |
||
360 | 'date column with default value' => [$date], |
||
361 | 'id column with auto increment' => [$id], |
||
362 | ]; |
||
363 | } |
||
364 | |||
365 | public function testCreateTableWithDeferredForeignKeys() |
||
366 | { |
||
367 | $table = new Table('user'); |
||
368 | $table->addColumn('id', 'integer'); |
||
369 | $table->addColumn('article', 'integer'); |
||
370 | $table->addColumn('post', 'integer'); |
||
371 | $table->addColumn('parent', 'integer'); |
||
372 | $table->setPrimaryKey(array('id')); |
||
373 | $table->addForeignKeyConstraint('article', array('article'), array('id'), array('deferrable' => true)); |
||
374 | $table->addForeignKeyConstraint('post', array('post'), array('id'), array('deferred' => true)); |
||
375 | $table->addForeignKeyConstraint('user', array('parent'), array('id'), array('deferrable' => true, 'deferred' => true)); |
||
376 | |||
377 | $sql = array( |
||
378 | 'CREATE TABLE user (' |
||
379 | . 'id INTEGER NOT NULL, article INTEGER NOT NULL, post INTEGER NOT NULL, parent INTEGER NOT NULL' |
||
380 | . ', PRIMARY KEY(id)' |
||
381 | . ', CONSTRAINT FK_8D93D64923A0E66 FOREIGN KEY (article) REFERENCES article (id) DEFERRABLE INITIALLY IMMEDIATE' |
||
382 | . ', CONSTRAINT FK_8D93D6495A8A6C8D FOREIGN KEY (post) REFERENCES post (id) NOT DEFERRABLE INITIALLY DEFERRED' |
||
383 | . ', CONSTRAINT FK_8D93D6493D8E604F FOREIGN KEY (parent) REFERENCES user (id) DEFERRABLE INITIALLY DEFERRED' |
||
384 | . ')', |
||
385 | 'CREATE INDEX IDX_8D93D64923A0E66 ON user (article)', |
||
386 | 'CREATE INDEX IDX_8D93D6495A8A6C8D ON user (post)', |
||
387 | 'CREATE INDEX IDX_8D93D6493D8E604F ON user (parent)', |
||
388 | ); |
||
389 | |||
390 | self::assertEquals($sql, $this->_platform->getCreateTableSQL($table)); |
||
391 | } |
||
392 | |||
393 | public function testAlterTable() |
||
394 | { |
||
395 | $table = new Table('user'); |
||
396 | $table->addColumn('id', 'integer'); |
||
397 | $table->addColumn('article', 'integer'); |
||
398 | $table->addColumn('post', 'integer'); |
||
399 | $table->addColumn('parent', 'integer'); |
||
400 | $table->setPrimaryKey(array('id')); |
||
401 | $table->addForeignKeyConstraint('article', array('article'), array('id'), array('deferrable' => true)); |
||
402 | $table->addForeignKeyConstraint('post', array('post'), array('id'), array('deferred' => true)); |
||
403 | $table->addForeignKeyConstraint('user', array('parent'), array('id'), array('deferrable' => true, 'deferred' => true)); |
||
404 | $table->addIndex(array('article', 'post'), 'index1'); |
||
405 | |||
406 | $diff = new TableDiff('user'); |
||
407 | $diff->fromTable = $table; |
||
408 | $diff->newName = 'client'; |
||
409 | $diff->renamedColumns['id'] = new \Doctrine\DBAL\Schema\Column('key', \Doctrine\DBAL\Types\Type::getType('integer'), array()); |
||
410 | $diff->renamedColumns['post'] = new \Doctrine\DBAL\Schema\Column('comment', \Doctrine\DBAL\Types\Type::getType('integer'), array()); |
||
411 | $diff->removedColumns['parent'] = new \Doctrine\DBAL\Schema\Column('comment', \Doctrine\DBAL\Types\Type::getType('integer'), array()); |
||
412 | $diff->removedIndexes['index1'] = $table->getIndex('index1'); |
||
413 | |||
414 | $sql = array( |
||
415 | 'DROP INDEX IDX_8D93D64923A0E66', |
||
416 | 'DROP INDEX IDX_8D93D6495A8A6C8D', |
||
417 | 'DROP INDEX IDX_8D93D6493D8E604F', |
||
418 | 'DROP INDEX index1', |
||
419 | 'CREATE TEMPORARY TABLE __temp__user AS SELECT id, article, post FROM user', |
||
420 | 'DROP TABLE user', |
||
421 | 'CREATE TABLE user (' |
||
422 | . '"key" INTEGER NOT NULL, article INTEGER NOT NULL, comment INTEGER NOT NULL' |
||
423 | . ', PRIMARY KEY("key")' |
||
424 | . ', CONSTRAINT FK_8D93D64923A0E66 FOREIGN KEY (article) REFERENCES article (id) DEFERRABLE INITIALLY IMMEDIATE' |
||
425 | . ', CONSTRAINT FK_8D93D6495A8A6C8D FOREIGN KEY (comment) REFERENCES post (id) NOT DEFERRABLE INITIALLY DEFERRED' |
||
426 | . ')', |
||
427 | 'INSERT INTO user ("key", article, comment) SELECT id, article, post FROM __temp__user', |
||
428 | 'DROP TABLE __temp__user', |
||
429 | 'ALTER TABLE user RENAME TO client', |
||
430 | 'CREATE INDEX IDX_8D93D64923A0E66 ON client (article)', |
||
431 | 'CREATE INDEX IDX_8D93D6495A8A6C8D ON client (comment)', |
||
432 | ); |
||
433 | |||
434 | self::assertEquals($sql, $this->_platform->getAlterTableSQL($diff)); |
||
435 | } |
||
436 | |||
437 | protected function getQuotedColumnInPrimaryKeySQL() |
||
438 | { |
||
439 | return array( |
||
440 | 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))', |
||
441 | ); |
||
442 | } |
||
443 | |||
444 | protected function getQuotedColumnInIndexSQL() |
||
445 | { |
||
446 | return array( |
||
447 | 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', |
||
448 | 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")', |
||
449 | ); |
||
450 | } |
||
451 | |||
452 | protected function getQuotedNameInIndexSQL() |
||
453 | { |
||
454 | return array( |
||
455 | 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', |
||
456 | 'CREATE INDEX "key" ON test (column1)', |
||
457 | ); |
||
458 | } |
||
459 | |||
460 | protected function getQuotedColumnInForeignKeySQL() |
||
461 | { |
||
462 | return array( |
||
463 | 'CREATE TABLE "quoted" (' . |
||
464 | '"create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, ' . |
||
465 | 'CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE, ' . |
||
466 | 'CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE, ' . |
||
467 | 'CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE)', |
||
468 | ); |
||
469 | } |
||
470 | |||
471 | protected function getBinaryDefaultLength() |
||
472 | { |
||
473 | return 0; |
||
474 | } |
||
475 | |||
476 | protected function getBinaryMaxLength() |
||
477 | { |
||
478 | return 0; |
||
479 | } |
||
480 | |||
481 | public function testReturnsBinaryTypeDeclarationSQL() |
||
482 | { |
||
483 | self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array())); |
||
484 | self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0))); |
||
485 | self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 9999999))); |
||
486 | |||
487 | self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true))); |
||
488 | self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0))); |
||
489 | self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 9999999))); |
||
490 | } |
||
491 | |||
492 | /** |
||
493 | * @group DBAL-234 |
||
494 | */ |
||
495 | protected function getAlterTableRenameIndexSQL() |
||
496 | { |
||
497 | return array( |
||
498 | 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id FROM mytable', |
||
499 | 'DROP TABLE mytable', |
||
500 | 'CREATE TABLE mytable (id INTEGER NOT NULL, PRIMARY KEY(id))', |
||
501 | 'INSERT INTO mytable (id) SELECT id FROM __temp__mytable', |
||
502 | 'DROP TABLE __temp__mytable', |
||
503 | 'CREATE INDEX idx_bar ON mytable (id)', |
||
504 | ); |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * @group DBAL-234 |
||
509 | */ |
||
510 | protected function getQuotedAlterTableRenameIndexSQL() |
||
520 | ); |
||
521 | } |
||
522 | |||
523 | /** |
||
524 | * {@inheritdoc} |
||
525 | */ |
||
526 | protected function getQuotedAlterTableRenameColumnSQL() |
||
543 | ); |
||
544 | } |
||
545 | |||
546 | /** |
||
547 | * {@inheritdoc} |
||
548 | */ |
||
549 | protected function getQuotedAlterTableChangeColumnLengthSQL() |
||
550 | { |
||
551 | return array( |
||
552 | 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM mytable', |
||
553 | 'DROP TABLE mytable', |
||
554 | 'CREATE TABLE mytable (unquoted1 VARCHAR(255) NOT NULL --Unquoted 1 |
||
555 | , unquoted2 VARCHAR(255) NOT NULL --Unquoted 2 |
||
556 | , unquoted3 VARCHAR(255) NOT NULL --Unquoted 3 |
||
557 | , "create" VARCHAR(255) NOT NULL --Reserved keyword 1 |
||
558 | , "table" VARCHAR(255) NOT NULL --Reserved keyword 2 |
||
559 | , "select" VARCHAR(255) NOT NULL --Reserved keyword 3 |
||
560 | )', |
||
561 | 'INSERT INTO mytable (unquoted1, unquoted2, unquoted3, "create", "table", "select") SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM __temp__mytable', |
||
562 | 'DROP TABLE __temp__mytable', |
||
563 | ); |
||
564 | } |
||
565 | |||
566 | /** |
||
567 | * @group DBAL-807 |
||
568 | */ |
||
569 | public function testAlterTableRenameIndexInSchema() |
||
570 | { |
||
571 | $this->markTestIncomplete( |
||
572 | 'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken ' . |
||
573 | 'when used with schemas.' |
||
574 | ); |
||
575 | } |
||
576 | |||
577 | /** |
||
578 | * @group DBAL-807 |
||
579 | */ |
||
580 | public function testQuotesAlterTableRenameIndexInSchema() |
||
581 | { |
||
582 | $this->markTestIncomplete( |
||
583 | 'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken ' . |
||
584 | 'when used with schemas.' |
||
585 | ); |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * @group DBAL-423 |
||
590 | */ |
||
591 | public function testReturnsGuidTypeDeclarationSQL() |
||
592 | { |
||
593 | self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array())); |
||
594 | } |
||
595 | |||
596 | /** |
||
597 | * {@inheritdoc} |
||
598 | */ |
||
599 | public function getAlterTableRenameColumnSQL() |
||
600 | { |
||
601 | return array( |
||
602 | 'CREATE TEMPORARY TABLE __temp__foo AS SELECT bar FROM foo', |
||
603 | 'DROP TABLE foo', |
||
604 | 'CREATE TABLE foo (baz INTEGER DEFAULT 666 NOT NULL --rename test |
||
605 | )', |
||
606 | 'INSERT INTO foo (baz) SELECT bar FROM __temp__foo', |
||
607 | 'DROP TABLE __temp__foo', |
||
608 | ); |
||
609 | } |
||
610 | |||
611 | /** |
||
612 | * {@inheritdoc} |
||
613 | */ |
||
614 | protected function getQuotesTableIdentifiersInAlterTableSQL() |
||
615 | { |
||
616 | return array( |
||
617 | 'DROP INDEX IDX_8C736521A81E660E', |
||
618 | 'DROP INDEX IDX_8C736521FDC58D6C', |
||
619 | 'CREATE TEMPORARY TABLE __temp__foo AS SELECT fk, fk2, id, fk3, bar FROM "foo"', |
||
620 | 'DROP TABLE "foo"', |
||
621 | 'CREATE TABLE "foo" (fk2 INTEGER NOT NULL, fk3 INTEGER NOT NULL, fk INTEGER NOT NULL, war INTEGER NOT NULL, ' . |
||
622 | 'bar INTEGER DEFAULT NULL, bloo INTEGER NOT NULL, ' . |
||
623 | 'CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id) NOT DEFERRABLE INITIALLY IMMEDIATE, ' . |
||
624 | 'CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE)', |
||
625 | 'INSERT INTO "foo" (fk, fk2, war, fk3, bar) SELECT fk, fk2, id, fk3, bar FROM __temp__foo', |
||
626 | 'DROP TABLE __temp__foo', |
||
627 | 'ALTER TABLE "foo" RENAME TO "table"', |
||
628 | 'CREATE INDEX IDX_8C736521A81E660E ON "table" (fk)', |
||
629 | 'CREATE INDEX IDX_8C736521FDC58D6C ON "table" (fk2)', |
||
630 | ); |
||
631 | } |
||
632 | |||
633 | /** |
||
634 | * {@inheritdoc} |
||
635 | */ |
||
636 | protected function getCommentOnColumnSQL() |
||
637 | { |
||
638 | return array( |
||
639 | 'COMMENT ON COLUMN foo.bar IS \'comment\'', |
||
640 | 'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'', |
||
641 | 'COMMENT ON COLUMN "select"."from" IS \'comment\'', |
||
642 | ); |
||
643 | } |
||
644 | |||
645 | protected function getInlineColumnCommentDelimiter() |
||
646 | { |
||
647 | return "\n"; |
||
648 | } |
||
649 | |||
650 | protected function getInlineColumnRegularCommentSQL() |
||
651 | { |
||
652 | return "--Regular comment\n"; |
||
653 | } |
||
654 | |||
655 | protected function getInlineColumnCommentRequiringEscapingSQL() |
||
658 | } |
||
659 | |||
660 | protected function getInlineColumnEmptyCommentSQL() |
||
661 | { |
||
662 | return "--\n"; |
||
663 | } |
||
664 | |||
665 | /** |
||
666 | * {@inheritdoc} |
||
667 | */ |
||
668 | protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() |
||
669 | { |
||
670 | return 'CONSTRAINT "select" UNIQUE (foo)'; |
||
671 | } |
||
672 | |||
673 | /** |
||
674 | * {@inheritdoc} |
||
675 | */ |
||
676 | protected function getQuotesReservedKeywordInIndexDeclarationSQL() |
||
677 | { |
||
678 | return 'INDEX "select" (foo)'; |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * {@inheritdoc} |
||
683 | */ |
||
684 | protected function getQuotesReservedKeywordInTruncateTableSQL() |
||
685 | { |
||
686 | return 'DELETE FROM "select"'; |
||
687 | } |
||
688 | |||
689 | /** |
||
690 | * {@inheritdoc} |
||
691 | */ |
||
692 | protected function getAlterStringToFixedStringSQL() |
||
693 | { |
||
694 | return array( |
||
695 | 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT name FROM mytable', |
||
696 | 'DROP TABLE mytable', |
||
697 | 'CREATE TABLE mytable (name CHAR(2) NOT NULL)', |
||
698 | 'INSERT INTO mytable (name) SELECT name FROM __temp__mytable', |
||
699 | 'DROP TABLE __temp__mytable', |
||
700 | ); |
||
701 | } |
||
702 | |||
703 | /** |
||
704 | * {@inheritdoc} |
||
705 | */ |
||
706 | protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() |
||
707 | { |
||
708 | return array( |
||
709 | 'DROP INDEX idx_foo', |
||
710 | 'DROP INDEX idx_bar', |
||
711 | 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT foo, bar, baz FROM mytable', |
||
712 | 'DROP TABLE mytable', |
||
713 | 'CREATE TABLE mytable (foo INTEGER NOT NULL, bar INTEGER NOT NULL, baz INTEGER NOT NULL, CONSTRAINT fk_foo FOREIGN KEY (foo) REFERENCES foreign_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT fk_bar FOREIGN KEY (bar) REFERENCES foreign_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE)', |
||
714 | 'INSERT INTO mytable (foo, bar, baz) SELECT foo, bar, baz FROM __temp__mytable', |
||
715 | 'DROP TABLE __temp__mytable', |
||
716 | 'CREATE INDEX idx_bar ON mytable (bar)', |
||
717 | 'CREATE INDEX idx_foo_renamed ON mytable (foo)', |
||
718 | ); |
||
719 | } |
||
720 | |||
721 | /** |
||
722 | * @group DBAL-2436 |
||
723 | */ |
||
724 | public function testQuotesTableNameInListTableConstraintsSQL() |
||
727 | } |
||
728 | |||
729 | /** |
||
730 | * @group DBAL-2436 |
||
731 | */ |
||
732 | public function testQuotesTableNameInListTableColumnsSQL() |
||
733 | { |
||
734 | self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); |
||
735 | } |
||
736 | |||
737 | /** |
||
738 | * @group DBAL-2436 |
||
739 | */ |
||
740 | public function testQuotesTableNameInListTableIndexesSQL() |
||
743 | } |
||
744 | |||
745 | /** |
||
746 | * @group DBAL-2436 |
||
747 | */ |
||
748 | public function testQuotesTableNameInListTableForeignKeysSQL() |
||
749 | { |
||
750 | self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); |
||
751 | } |
||
752 | |||
753 | public function testDateAddStaticNumberOfDays() |
||
754 | { |
||
755 | self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->_platform->getDateAddDaysExpression('rentalBeginsOn', 12)); |
||
756 | } |
||
757 | |||
758 | public function testDateAddNumberOfDaysFromColumn() |
||
759 | { |
||
760 | self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->_platform->getDateAddDaysExpression('rentalBeginsOn', 'duration')); |
||
761 | } |
||
762 | |||
763 | public function testSupportsColumnCollation() : void |
||
764 | { |
||
765 | self::assertTrue($this->_platform->supportsColumnCollation()); |
||
766 | } |
||
767 | |||
768 | public function testColumnCollationDeclarationSQL() : void |
||
769 | { |
||
770 | self::assertSame( |
||
771 | 'COLLATE NOCASE', |
||
772 | $this->_platform->getColumnCollationDeclarationSQL('NOCASE') |
||
773 | ); |
||
774 | } |
||
775 | |||
776 | public function testGetCreateTableSQLWithColumnCollation() : void |
||
786 | ); |
||
787 | } |
||
789 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.