Passed
Push — master ( 5a192c...be45cd )
by Sergei
28:04
created

testModifiesLimitQueryWithoutLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Platforms;
4
5
use Doctrine\DBAL\DBALException;
6
use Doctrine\DBAL\LockMode;
7
use Doctrine\DBAL\Platforms\AbstractPlatform;
8
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
9
use Doctrine\DBAL\Platforms\TrimMode;
10
use Doctrine\DBAL\Schema\Column;
11
use Doctrine\DBAL\Schema\ColumnDiff;
12
use Doctrine\DBAL\Schema\Comparator;
13
use Doctrine\DBAL\Schema\Constraint;
14
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
15
use Doctrine\DBAL\Schema\Index;
16
use Doctrine\DBAL\Schema\Table;
17
use Doctrine\DBAL\Schema\TableDiff;
18
use Doctrine\DBAL\TransactionIsolationLevel;
19
use Doctrine\DBAL\Types\Type;
20
use InvalidArgumentException;
21
use function mt_rand;
22
use function strlen;
23
use function substr;
24
25
class SQLAnywherePlatformTest extends AbstractPlatformTestCase
26
{
27
    /** @var SQLAnywherePlatform */
28
    protected $platform;
29
30
    public function createPlatform()
31
    {
32
        return new SQLAnywherePlatform();
33
    }
34
35
    public function getGenerateAlterTableSql()
36
    {
37
        return [
38
            "ALTER TABLE mytable ADD quota INT DEFAULT NULL, DROP foo, ALTER baz VARCHAR(1) DEFAULT 'def' NOT NULL, ALTER bloo BIT DEFAULT '0' NOT NULL",
39
            'ALTER TABLE mytable RENAME userlist',
40
        ];
41
    }
42
43
    public function getGenerateForeignKeySql()
44
    {
45
        return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)';
46
    }
47
48
    public function getGenerateIndexSql()
49
    {
50
        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
51
    }
52
53
    public function getGenerateTableSql()
54
    {
55
        return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY (id))';
56
    }
57
58
    public function getGenerateTableWithMultiColumnUniqueIndexSql()
59
    {
60
        return [
61
            'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
62
            'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
63
        ];
64
    }
65
66
    public function getGenerateUniqueIndexSql()
67
    {
68
        return 'CREATE UNIQUE INDEX index_name ON test (test, test2)';
69
    }
70
71
    protected function getQuotedColumnInForeignKeySQL()
72
    {
73
        return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar"))'];
74
    }
75
76
    protected function getQuotedColumnInIndexSQL()
77
    {
78
        return [
79
            'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
80
            'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
81
        ];
82
    }
83
84
    protected function getQuotedNameInIndexSQL()
85
    {
86
        return [
87
            'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)',
88
            'CREATE INDEX "key" ON test (column1)',
89
        ];
90
    }
91
92
    protected function getQuotedColumnInPrimaryKeySQL()
93
    {
94
        return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY ("create"))'];
95
    }
96
97
    public function getCreateTableColumnCommentsSQL()
98
    {
99
        return [
100
            'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))',
101
            "COMMENT ON COLUMN test.id IS 'This is a comment'",
102
        ];
103
    }
104
105
    public function getAlterTableColumnCommentsSQL()
106
    {
107
        return [
108
            'ALTER TABLE mytable ADD quota INT NOT NULL',
109
            "COMMENT ON COLUMN mytable.quota IS 'A comment'",
110
            'COMMENT ON COLUMN mytable.foo IS NULL',
111
            "COMMENT ON COLUMN mytable.baz IS 'B comment'",
112
        ];
113
    }
114
115
    public function getCreateTableColumnTypeCommentsSQL()
116
    {
117
        return [
118
            'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY (id))',
119
            "COMMENT ON COLUMN test.data IS '(DC2Type:array)'",
120
        ];
121
    }
122
123
    public function testHasCorrectPlatformName()
124
    {
125
        self::assertEquals('sqlanywhere', $this->platform->getName());
126
    }
127
128
    public function testGeneratesCreateTableSQLWithCommonIndexes()
129
    {
130
        $table = new Table('test');
131
        $table->addColumn('id', 'integer');
132
        $table->addColumn('name', 'string', ['length' => 50]);
133
        $table->setPrimaryKey(['id']);
134
        $table->addIndex(['name']);
135
        $table->addIndex(['id', 'name'], 'composite_idx');
136
137
        self::assertEquals(
138
            [
139
                'CREATE TABLE test (id INT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY (id))',
140
                'CREATE INDEX IDX_D87F7E0C5E237E06 ON test (name)',
141
                'CREATE INDEX composite_idx ON test (id, name)',
142
            ],
143
            $this->platform->getCreateTableSQL($table)
144
        );
145
    }
146
147
    public function testGeneratesCreateTableSQLWithForeignKeyConstraints()
148
    {
149
        $table = new Table('test');
150
        $table->addColumn('id', 'integer');
151
        $table->addColumn('fk_1', 'integer');
152
        $table->addColumn('fk_2', 'integer');
153
        $table->setPrimaryKey(['id']);
154
        $table->addForeignKeyConstraint('foreign_table', ['fk_1', 'fk_2'], ['pk_1', 'pk_2']);
155
        $table->addForeignKeyConstraint(
156
            'foreign_table2',
157
            ['fk_1', 'fk_2'],
158
            ['pk_1', 'pk_2'],
159
            [],
160
            'named_fk'
161
        );
162
163
        self::assertEquals(
164
            ['CREATE TABLE test (id INT NOT NULL, fk_1 INT NOT NULL, fk_2 INT NOT NULL, ' .
165
                'CONSTRAINT FK_D87F7E0C177612A38E7F4319 FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table (pk_1, pk_2), ' .
166
                'CONSTRAINT named_fk FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table2 (pk_1, pk_2))',
167
            ],
168
            $this->platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS)
169
        );
170
    }
171
172
    public function testGeneratesCreateTableSQLWithCheckConstraints()
173
    {
174
        $table = new Table('test');
175
        $table->addColumn('id', 'integer');
176
        $table->addColumn('check_max', 'integer', ['platformOptions' => ['max' => 10]]);
177
        $table->addColumn('check_min', 'integer', ['platformOptions' => ['min' => 10]]);
178
        $table->setPrimaryKey(['id']);
179
180
        self::assertEquals(
181
            ['CREATE TABLE test (id INT NOT NULL, check_max INT NOT NULL, check_min INT NOT NULL, PRIMARY KEY (id), CHECK (check_max <= 10), CHECK (check_min >= 10))'],
182
            $this->platform->getCreateTableSQL($table)
183
        );
184
    }
185
186
    public function testGeneratesTableAlterationWithRemovedColumnCommentSql()
187
    {
188
        $table = new Table('mytable');
189
        $table->addColumn('foo', 'string', ['comment' => 'foo comment']);
190
191
        $tableDiff                        = new TableDiff('mytable');
192
        $tableDiff->fromTable             = $table;
193
        $tableDiff->changedColumns['foo'] = new ColumnDiff(
194
            'foo',
195
            new Column('foo', Type::getType('string')),
196
            ['comment']
197
        );
198
199
        self::assertEquals(
200
            ['COMMENT ON COLUMN mytable.foo IS NULL'],
201
            $this->platform->getAlterTableSQL($tableDiff)
202
        );
203
    }
204
205
    /**
206
     * @dataProvider getLockHints
207
     */
208
    public function testAppendsLockHint($lockMode, $lockHint)
209
    {
210
        $fromClause     = 'FROM users';
211
        $expectedResult = $fromClause . $lockHint;
212
213
        self::assertSame($expectedResult, $this->platform->appendLockHint($fromClause, $lockMode));
214
    }
215
216
    public function getLockHints()
217
    {
218
        return [
219
            [null, ''],
220
            [false, ''],
221
            [true, ''],
222
            [LockMode::NONE, ' WITH (NOLOCK)'],
223
            [LockMode::OPTIMISTIC, ''],
224
            [LockMode::PESSIMISTIC_READ, ' WITH (UPDLOCK)'],
225
            [LockMode::PESSIMISTIC_WRITE, ' WITH (XLOCK)'],
226
        ];
227
    }
228
229
    public function testHasCorrectMaxIdentifierLength()
230
    {
231
        self::assertEquals(128, $this->platform->getMaxIdentifierLength());
232
    }
233
234
    public function testFixesSchemaElementNames()
235
    {
236
        $maxIdentifierLength = $this->platform->getMaxIdentifierLength();
237
        $characters          = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
238
        $schemaElementName   = '';
239
240
        for ($i = 0; $i < $maxIdentifierLength + 100; $i++) {
241
            $schemaElementName .= $characters[mt_rand(0, strlen($characters) - 1)];
242
        }
243
244
        $fixedSchemaElementName = substr($schemaElementName, 0, $maxIdentifierLength);
245
246
        self::assertEquals(
247
            $fixedSchemaElementName,
248
            $this->platform->fixSchemaElementName($schemaElementName)
249
        );
250
        self::assertEquals(
251
            $fixedSchemaElementName,
252
            $this->platform->fixSchemaElementName($fixedSchemaElementName)
253
        );
254
    }
255
256
    public function testGeneratesColumnTypesDeclarationSQL()
257
    {
258
        $fullColumnDef = [
259
            'length' => 10,
260
            'fixed' => true,
261
            'unsigned' => true,
262
            'autoincrement' => true,
263
        ];
264
265
        self::assertEquals('SMALLINT', $this->platform->getSmallIntTypeDeclarationSQL([]));
266
        self::assertEquals('UNSIGNED SMALLINT', $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => true]));
267
        self::assertEquals('UNSIGNED SMALLINT IDENTITY', $this->platform->getSmallIntTypeDeclarationSQL($fullColumnDef));
268
        self::assertEquals('INT', $this->platform->getIntegerTypeDeclarationSQL([]));
269
        self::assertEquals('UNSIGNED INT', $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => true]));
270
        self::assertEquals('UNSIGNED INT IDENTITY', $this->platform->getIntegerTypeDeclarationSQL($fullColumnDef));
271
        self::assertEquals('BIGINT', $this->platform->getBigIntTypeDeclarationSQL([]));
272
        self::assertEquals('UNSIGNED BIGINT', $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => true]));
273
        self::assertEquals('UNSIGNED BIGINT IDENTITY', $this->platform->getBigIntTypeDeclarationSQL($fullColumnDef));
274
        self::assertEquals('LONG BINARY', $this->platform->getBlobTypeDeclarationSQL($fullColumnDef));
275
        self::assertEquals('BIT', $this->platform->getBooleanTypeDeclarationSQL($fullColumnDef));
276
        self::assertEquals('TEXT', $this->platform->getClobTypeDeclarationSQL($fullColumnDef));
277
        self::assertEquals('DATE', $this->platform->getDateTypeDeclarationSQL($fullColumnDef));
278
        self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL($fullColumnDef));
279
        self::assertEquals('TIME', $this->platform->getTimeTypeDeclarationSQL($fullColumnDef));
280
        self::assertEquals('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL($fullColumnDef));
281
282
        self::assertEquals(1, $this->platform->getVarcharDefaultLength());
283
        self::assertEquals(32767, $this->platform->getVarcharMaxLength());
284
    }
285
286
    public function testHasNativeGuidType()
287
    {
288
        self::assertTrue($this->platform->hasNativeGuidType());
289
    }
290
291
    public function testGeneratesDDLSnippets()
292
    {
293
        self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('foobar'));
294
        self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('"foobar"'));
295
        self::assertEquals("CREATE DATABASE 'create'", $this->platform->getCreateDatabaseSQL('create'));
296
        self::assertEquals("DROP DATABASE 'foobar'", $this->platform->getDropDatabaseSQL('foobar'));
297
        self::assertEquals("DROP DATABASE 'foobar'", $this->platform->getDropDatabaseSQL('"foobar"'));
298
        self::assertEquals("DROP DATABASE 'create'", $this->platform->getDropDatabaseSQL('create'));
299
        self::assertEquals('CREATE GLOBAL TEMPORARY TABLE', $this->platform->getCreateTemporaryTableSnippetSQL());
300
        self::assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->platform->getStartDatabaseSQL('foobar'));
301
        self::assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->platform->getStartDatabaseSQL('"foobar"'));
302
        self::assertEquals("START DATABASE 'create' AUTOSTOP OFF", $this->platform->getStartDatabaseSQL('create'));
303
        self::assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->platform->getStopDatabaseSQL('foobar'));
304
        self::assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->platform->getStopDatabaseSQL('"foobar"'));
305
        self::assertEquals('STOP DATABASE "create" UNCONDITIONALLY', $this->platform->getStopDatabaseSQL('create'));
306
        self::assertEquals('TRUNCATE TABLE foobar', $this->platform->getTruncateTableSQL('foobar'));
307
        self::assertEquals('TRUNCATE TABLE foobar', $this->platform->getTruncateTableSQL('foobar'), true);
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type string expected by parameter $message of PHPUnit\Framework\Assert::assertEquals(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

307
        self::assertEquals('TRUNCATE TABLE foobar', $this->platform->getTruncateTableSQL('foobar'), /** @scrutinizer ignore-type */ true);
Loading history...
308
309
        $viewSql = 'SELECT * FROM footable';
310
        self::assertEquals('CREATE VIEW fooview AS ' . $viewSql, $this->platform->getCreateViewSQL('fooview', $viewSql));
311
        self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview'));
312
    }
313
314
    public function testGeneratesPrimaryKeyDeclarationSQL()
315
    {
316
        self::assertEquals(
317
            'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)',
318
            $this->platform->getPrimaryKeyDeclarationSQL(
319
                new Index(null, ['a', 'b'], true, true, ['clustered']),
320
                'pk'
321
            )
322
        );
323
        self::assertEquals(
324
            'PRIMARY KEY (a, b)',
325
            $this->platform->getPrimaryKeyDeclarationSQL(
326
                new Index(null, ['a', 'b'], true, true)
327
            )
328
        );
329
    }
330
331
    public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns()
332
    {
333
        $this->expectException(InvalidArgumentException::class);
334
335
        $this->platform->getPrimaryKeyDeclarationSQL(new Index('pk', [], true, true));
336
    }
337
338
    public function testGeneratesCreateUnnamedPrimaryKeySQL()
339
    {
340
        self::assertEquals(
341
            'ALTER TABLE foo ADD PRIMARY KEY CLUSTERED (a, b)',
342
            $this->platform->getCreatePrimaryKeySQL(
343
                new Index('pk', ['a', 'b'], true, true, ['clustered']),
344
                'foo'
345
            )
346
        );
347
        self::assertEquals(
348
            'ALTER TABLE foo ADD PRIMARY KEY (a, b)',
349
            $this->platform->getCreatePrimaryKeySQL(
350
                new Index('any_pk_name', ['a', 'b'], true, true),
351
                new Table('foo')
352
            )
353
        );
354
    }
355
356
    public function testGeneratesUniqueConstraintDeclarationSQL()
357
    {
358
        self::assertEquals(
359
            'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)',
360
            $this->platform->getUniqueConstraintDeclarationSQL(
361
                'unique_constraint',
362
                new Index(null, ['a', 'b'], true, false, ['clustered'])
363
            )
364
        );
365
        self::assertEquals(
366
            'UNIQUE (a, b)',
367
            $this->platform->getUniqueConstraintDeclarationSQL(null, new Index(null, ['a', 'b'], true, false))
368
        );
369
    }
370
371
    public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns()
372
    {
373
        $this->expectException(InvalidArgumentException::class);
374
375
        $this->platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', [], true));
376
    }
377
378
    public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL()
379
    {
380
        self::assertEquals(
381
            'CONSTRAINT fk ' .
382
                'NOT NULL FOREIGN KEY (a, b) ' .
383
                'REFERENCES foreign_table (c, d) ' .
384
                'MATCH UNIQUE SIMPLE ON UPDATE CASCADE ON DELETE SET NULL CHECK ON COMMIT CLUSTERED FOR OLAP WORKLOAD',
385
            $this->platform->getForeignKeyDeclarationSQL(
386
                new ForeignKeyConstraint(['a', 'b'], 'foreign_table', ['c', 'd'], 'fk', [
387
                    'notnull' => true,
388
                    'match' => SQLAnywherePlatform::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE,
389
                    'onUpdate' => 'CASCADE',
390
                    'onDelete' => 'SET NULL',
391
                    'check_on_commit' => true,
392
                    'clustered' => true,
393
                    'for_olap_workload' => true,
394
                ])
395
            )
396
        );
397
        self::assertEquals(
398
            'FOREIGN KEY (a, b) REFERENCES foreign_table (c, d)',
399
            $this->platform->getForeignKeyDeclarationSQL(
400
                new ForeignKeyConstraint(['a', 'b'], 'foreign_table', ['c', 'd'])
401
            )
402
        );
403
    }
404
405
    public function testGeneratesForeignKeyMatchClausesSQL()
406
    {
407
        self::assertEquals('SIMPLE', $this->platform->getForeignKeyMatchClauseSQL(1));
408
        self::assertEquals('FULL', $this->platform->getForeignKeyMatchClauseSQL(2));
409
        self::assertEquals('UNIQUE SIMPLE', $this->platform->getForeignKeyMatchClauseSQL(129));
410
        self::assertEquals('UNIQUE FULL', $this->platform->getForeignKeyMatchClauseSQL(130));
411
    }
412
413
    public function testCannotGenerateInvalidForeignKeyMatchClauseSQL()
414
    {
415
        $this->expectException(InvalidArgumentException::class);
416
417
        $this->platform->getForeignKeyMatchCLauseSQL(3);
418
    }
419
420
    public function testCannotGenerateForeignKeyConstraintSQLWithEmptyLocalColumns()
421
    {
422
        $this->expectException(InvalidArgumentException::class);
423
        $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint([], 'foreign_tbl', ['c', 'd']));
424
    }
425
426
    public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignColumns()
427
    {
428
        $this->expectException(InvalidArgumentException::class);
429
        $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], 'foreign_tbl', []));
430
    }
431
432
    public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName()
433
    {
434
        $this->expectException(InvalidArgumentException::class);
435
        $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], '', ['c', 'd']));
436
    }
437
438
    public function testCannotGenerateCommonIndexWithCreateConstraintSQL()
439
    {
440
        $this->expectException(InvalidArgumentException::class);
441
442
        $this->platform->getCreateConstraintSQL(new Index('fooindex', []), new Table('footable'));
443
    }
444
445
    public function testCannotGenerateCustomConstraintWithCreateConstraintSQL()
446
    {
447
        $this->expectException(InvalidArgumentException::class);
448
449
        $this->platform->getCreateConstraintSQL($this->createMock(Constraint::class), 'footable');
450
    }
451
452
    public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
453
    {
454
        self::assertEquals(
455
            'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD',
456
            $this->platform->getCreateIndexSQL(
457
                new Index(
458
                    'fooindex',
459
                    ['a', 'b'],
460
                    true,
461
                    false,
462
                    ['virtual', 'clustered', 'for_olap_workload']
463
                ),
464
                'footable'
465
            )
466
        );
467
    }
468
469
    public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements()
470
    {
471
        $this->expectException(DBALException::class);
472
473
        $this->platform->getIndexDeclarationSQL('index', new Index('index', []));
474
    }
475
476
    public function testGeneratesDropIndexSQL()
477
    {
478
        $index = new Index('fooindex', []);
479
480
        self::assertEquals('DROP INDEX fooindex', $this->platform->getDropIndexSQL($index));
481
        self::assertEquals('DROP INDEX footable.fooindex', $this->platform->getDropIndexSQL($index, 'footable'));
482
        self::assertEquals('DROP INDEX footable.fooindex', $this->platform->getDropIndexSQL(
483
            $index,
484
            new Table('footable')
485
        ));
486
    }
487
488
    public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter()
489
    {
490
        $this->expectException(InvalidArgumentException::class);
491
492
        $this->platform->getDropIndexSQL(['index'], 'table');
493
    }
494
495
    public function testCannotGenerateDropIndexSQLWithInvalidTableParameter()
496
    {
497
        $this->expectException(InvalidArgumentException::class);
498
499
        $this->platform->getDropIndexSQL('index', ['table']);
500
    }
501
502
    public function testGeneratesSQLSnippets()
503
    {
504
        self::assertEquals('STRING(column1, "string1", column2, "string2")', $this->platform->getConcatExpression(
505
            'column1',
506
            '"string1"',
507
            'column2',
508
            '"string2"'
509
        ));
510
        self::assertEquals('CURRENT DATE', $this->platform->getCurrentDateSQL());
511
        self::assertEquals('CURRENT TIME', $this->platform->getCurrentTimeSQL());
512
        self::assertEquals('CURRENT TIMESTAMP', $this->platform->getCurrentTimestampSQL());
513
        self::assertEquals("DATEADD(DAY, 4, '1987/05/02')", $this->platform->getDateAddDaysExpression("'1987/05/02'", 4));
514
        self::assertEquals("DATEADD(HOUR, 12, '1987/05/02')", $this->platform->getDateAddHourExpression("'1987/05/02'", 12));
515
        self::assertEquals("DATEADD(MINUTE, 2, '1987/05/02')", $this->platform->getDateAddMinutesExpression("'1987/05/02'", 2));
516
        self::assertEquals("DATEADD(MONTH, 102, '1987/05/02')", $this->platform->getDateAddMonthExpression("'1987/05/02'", 102));
517
        self::assertEquals("DATEADD(QUARTER, 5, '1987/05/02')", $this->platform->getDateAddQuartersExpression("'1987/05/02'", 5));
518
        self::assertEquals("DATEADD(SECOND, 1, '1987/05/02')", $this->platform->getDateAddSecondsExpression("'1987/05/02'", 1));
519
        self::assertEquals("DATEADD(WEEK, 3, '1987/05/02')", $this->platform->getDateAddWeeksExpression("'1987/05/02'", 3));
520
        self::assertEquals("DATEADD(YEAR, 10, '1987/05/02')", $this->platform->getDateAddYearsExpression("'1987/05/02'", 10));
521
        self::assertEquals("DATEDIFF(day, '1987/04/01', '1987/05/02')", $this->platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'"));
522
        self::assertEquals("DATEADD(DAY, -1 * 4, '1987/05/02')", $this->platform->getDateSubDaysExpression("'1987/05/02'", 4));
523
        self::assertEquals("DATEADD(HOUR, -1 * 12, '1987/05/02')", $this->platform->getDateSubHourExpression("'1987/05/02'", 12));
524
        self::assertEquals("DATEADD(MINUTE, -1 * 2, '1987/05/02')", $this->platform->getDateSubMinutesExpression("'1987/05/02'", 2));
525
        self::assertEquals("DATEADD(MONTH, -1 * 102, '1987/05/02')", $this->platform->getDateSubMonthExpression("'1987/05/02'", 102));
526
        self::assertEquals("DATEADD(QUARTER, -1 * 5, '1987/05/02')", $this->platform->getDateSubQuartersExpression("'1987/05/02'", 5));
527
        self::assertEquals("DATEADD(SECOND, -1 * 1, '1987/05/02')", $this->platform->getDateSubSecondsExpression("'1987/05/02'", 1));
528
        self::assertEquals("DATEADD(WEEK, -1 * 3, '1987/05/02')", $this->platform->getDateSubWeeksExpression("'1987/05/02'", 3));
529
        self::assertEquals("DATEADD(YEAR, -1 * 10, '1987/05/02')", $this->platform->getDateSubYearsExpression("'1987/05/02'", 10));
530
        self::assertEquals('Y-m-d H:i:s.u', $this->platform->getDateTimeFormatString());
531
        self::assertEquals('H:i:s.u', $this->platform->getTimeFormatString());
532
        self::assertEquals('', $this->platform->getForUpdateSQL());
533
        self::assertEquals('NEWID()', $this->platform->getGuidExpression());
1 ignored issue
show
Deprecated Code introduced by
The function Doctrine\DBAL\Platforms\...rm::getGuidExpression() has been deprecated: Use application-generated UUIDs instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

533
        self::assertEquals('NEWID()', /** @scrutinizer ignore-deprecated */ $this->platform->getGuidExpression());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
534
        self::assertEquals('LOCATE(string_column, substring_column)', $this->platform->getLocateExpression('string_column', 'substring_column'));
535
        self::assertEquals('LOCATE(string_column, substring_column, 1)', $this->platform->getLocateExpression('string_column', 'substring_column', 1));
536
        self::assertEquals("HASH(column, 'MD5')", $this->platform->getMd5Expression('column'));
537
        self::assertEquals('SUBSTRING(column, 5)', $this->platform->getSubstringExpression('column', 5));
538
        self::assertEquals('SUBSTRING(column, 5, 2)', $this->platform->getSubstringExpression('column', 5, 2));
539
        self::assertEquals('GLOBAL TEMPORARY', $this->platform->getTemporaryTableSQL());
540
        self::assertEquals(
541
            'LTRIM(column)',
542
            $this->platform->getTrimExpression('column', TrimMode::LEADING)
543
        );
544
        self::assertEquals(
545
            'RTRIM(column)',
546
            $this->platform->getTrimExpression('column', TrimMode::TRAILING)
547
        );
548
        self::assertEquals(
549
            'TRIM(column)',
550
            $this->platform->getTrimExpression('column')
551
        );
552
        self::assertEquals(
553
            'TRIM(column)',
554
            $this->platform->getTrimExpression('column', TrimMode::UNSPECIFIED)
555
        );
556
        self::assertEquals(
557
            "SUBSTR(column, PATINDEX('%[^' + c + ']%', column))",
558
            $this->platform->getTrimExpression('column', TrimMode::LEADING, 'c')
559
        );
560
        self::assertEquals(
561
            "REVERSE(SUBSTR(REVERSE(column), PATINDEX('%[^' + c + ']%', REVERSE(column))))",
562
            $this->platform->getTrimExpression('column', TrimMode::TRAILING, 'c')
563
        );
564
        self::assertEquals(
565
            "REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
566
            "REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))",
567
            $this->platform->getTrimExpression('column', null, 'c')
568
        );
569
        self::assertEquals(
570
            "REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
571
            "REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))",
572
            $this->platform->getTrimExpression('column', TrimMode::UNSPECIFIED, 'c')
573
        );
574
    }
575
576
    public function testDoesNotSupportRegexp()
577
    {
578
        $this->expectException(DBALException::class);
579
580
        $this->platform->getRegexpExpression();
581
    }
582
583
    public function testHasCorrectDateTimeTzFormatString()
584
    {
585
        // Date time type with timezone is not supported before version 12.
586
        // For versions before we have to ensure that the date time with timezone format
587
        // equals the normal date time format so that it corresponds to the declaration SQL equality (datetimetz -> datetime).
588
        self::assertEquals($this->platform->getDateTimeFormatString(), $this->platform->getDateTimeTzFormatString());
589
    }
590
591
    public function testHasCorrectDefaultTransactionIsolationLevel()
592
    {
593
        self::assertEquals(
594
            TransactionIsolationLevel::READ_UNCOMMITTED,
595
            $this->platform->getDefaultTransactionIsolationLevel()
596
        );
597
    }
598
599
    public function testGeneratesTransactionsCommands()
600
    {
601
        self::assertEquals(
602
            'SET TEMPORARY OPTION isolation_level = 0',
603
            $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
604
        );
605
        self::assertEquals(
606
            'SET TEMPORARY OPTION isolation_level = 1',
607
            $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
608
        );
609
        self::assertEquals(
610
            'SET TEMPORARY OPTION isolation_level = 2',
611
            $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
612
        );
613
        self::assertEquals(
614
            'SET TEMPORARY OPTION isolation_level = 3',
615
            $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
616
        );
617
    }
618
619
    public function testCannotGenerateTransactionCommandWithInvalidIsolationLevel()
620
    {
621
        $this->expectException(InvalidArgumentException::class);
622
623
        $this->platform->getSetTransactionIsolationSQL('invalid_transaction_isolation_level');
624
    }
625
626
    public function testModifiesLimitQuery()
627
    {
628
        self::assertEquals(
629
            'SELECT TOP 10 * FROM user',
630
            $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0)
631
        );
632
    }
633
634
    public function testModifiesLimitQueryWithEmptyOffset()
635
    {
636
        self::assertEquals(
637
            'SELECT TOP 10 * FROM user',
638
            $this->platform->modifyLimitQuery('SELECT * FROM user', 10)
639
        );
640
    }
641
642
    public function testModifiesLimitQueryWithOffset()
643
    {
644
        self::assertEquals(
645
            'SELECT TOP 10 START AT 6 * FROM user',
646
            $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 5)
647
        );
648
        self::assertEquals(
649
            'SELECT TOP 0 START AT 6 * FROM user',
650
            $this->platform->modifyLimitQuery('SELECT * FROM user', 0, 5)
651
        );
652
    }
653
654
    public function testModifiesLimitQueryWithSubSelect()
655
    {
656
        self::assertEquals(
657
            'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl',
658
            $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl', 10)
659
        );
660
    }
661
662
    public function testModifiesLimitQueryWithoutLimit()
663
    {
664
        self::assertEquals(
665
            'SELECT TOP ALL START AT 11 n FROM Foo',
666
            $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10)
667
        );
668
    }
669
670
    public function testPrefersIdentityColumns()
671
    {
672
        self::assertTrue($this->platform->prefersIdentityColumns());
673
    }
674
675
    public function testDoesNotPreferSequences()
676
    {
677
        self::assertFalse($this->platform->prefersSequences());
678
    }
679
680
    public function testSupportsIdentityColumns()
681
    {
682
        self::assertTrue($this->platform->supportsIdentityColumns());
683
    }
684
685
    public function testSupportsPrimaryConstraints()
686
    {
687
        self::assertTrue($this->platform->supportsPrimaryConstraints());
688
    }
689
690
    public function testSupportsForeignKeyConstraints()
691
    {
692
        self::assertTrue($this->platform->supportsForeignKeyConstraints());
693
    }
694
695
    public function testSupportsForeignKeyOnUpdate()
696
    {
697
        self::assertTrue($this->platform->supportsForeignKeyOnUpdate());
698
    }
699
700
    public function testSupportsAlterTable()
701
    {
702
        self::assertTrue($this->platform->supportsAlterTable());
703
    }
704
705
    public function testSupportsTransactions()
706
    {
707
        self::assertTrue($this->platform->supportsTransactions());
708
    }
709
710
    public function testSupportsSchemas()
711
    {
712
        self::assertFalse($this->platform->supportsSchemas());
713
    }
714
715
    public function testSupportsIndexes()
716
    {
717
        self::assertTrue($this->platform->supportsIndexes());
718
    }
719
720
    public function testSupportsCommentOnStatement()
721
    {
722
        self::assertTrue($this->platform->supportsCommentOnStatement());
723
    }
724
725
    public function testSupportsSavePoints()
726
    {
727
        self::assertTrue($this->platform->supportsSavepoints());
728
    }
729
730
    public function testSupportsReleasePoints()
731
    {
732
        self::assertTrue($this->platform->supportsReleaseSavepoints());
733
    }
734
735
    public function testSupportsCreateDropDatabase()
736
    {
737
        self::assertTrue($this->platform->supportsCreateDropDatabase());
738
    }
739
740
    public function testSupportsGettingAffectedRows()
741
    {
742
        self::assertTrue($this->platform->supportsGettingAffectedRows());
743
    }
744
745
    public function testDoesNotSupportSequences()
746
    {
747
        self::assertFalse($this->platform->supportsSequences());
748
    }
749
750
    public function testDoesNotSupportInlineColumnComments()
751
    {
752
        self::assertFalse($this->platform->supportsInlineColumnComments());
753
    }
754
755
    public function testCannotEmulateSchemas()
756
    {
757
        self::assertFalse($this->platform->canEmulateSchemas());
758
    }
759
760
    public function testInitializesDoctrineTypeMappings()
761
    {
762
        self::assertTrue($this->platform->hasDoctrineTypeMappingFor('integer'));
763
        self::assertSame('integer', $this->platform->getDoctrineTypeMapping('integer'));
764
765
        self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary'));
766
        self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary'));
767
768
        self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varbinary'));
769
        self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary'));
770
    }
771
772
    protected function getBinaryDefaultLength()
773
    {
774
        return 1;
775
    }
776
777
    protected function getBinaryMaxLength()
778
    {
779
        return 32767;
780
    }
781
782
    public function testReturnsBinaryTypeDeclarationSQL()
783
    {
784
        self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL([]));
785
        self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
786
        self::assertSame('VARBINARY(32767)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32767]));
787
788
        self::assertSame('BINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
789
        self::assertSame('BINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
790
        self::assertSame('BINARY(32767)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32767]));
791
    }
792
793
    /**
794
     * @group legacy
795
     * @expectedDeprecation Binary field length 32768 is greater than supported by the platform (32767). Reduce the field length or use a BLOB field instead.
796
     */
797
    public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
798
    {
799
        self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32768]));
800
        self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32768]));
801
    }
802
803
    /**
804
     * @group DBAL-234
805
     */
806
    protected function getAlterTableRenameIndexSQL()
807
    {
808
        return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_bar'];
809
    }
810
811
    /**
812
     * @group DBAL-234
813
     */
814
    protected function getQuotedAlterTableRenameIndexSQL()
815
    {
816
        return [
817
            'ALTER INDEX "create" ON "table" RENAME TO "select"',
818
            'ALTER INDEX "foo" ON "table" RENAME TO "bar"',
819
        ];
820
    }
821
822
    /**
823
     * {@inheritdoc}
824
     */
825
    protected function getQuotedAlterTableRenameColumnSQL()
826
    {
827
        return [
828
            'ALTER TABLE mytable RENAME unquoted1 TO unquoted',
829
            'ALTER TABLE mytable RENAME unquoted2 TO "where"',
830
            'ALTER TABLE mytable RENAME unquoted3 TO "foo"',
831
            'ALTER TABLE mytable RENAME "create" TO reserved_keyword',
832
            'ALTER TABLE mytable RENAME "table" TO "from"',
833
            'ALTER TABLE mytable RENAME "select" TO "bar"',
834
            'ALTER TABLE mytable RENAME quoted1 TO quoted',
835
            'ALTER TABLE mytable RENAME quoted2 TO "and"',
836
            'ALTER TABLE mytable RENAME quoted3 TO "baz"',
837
        ];
838
    }
839
840
    /**
841
     * {@inheritdoc}
842
     */
843
    protected function getQuotedAlterTableChangeColumnLengthSQL()
844
    {
845
        $this->markTestIncomplete('Not implemented yet');
846
    }
847
848
    /**
849
     * @group DBAL-807
850
     */
851
    protected function getAlterTableRenameIndexInSchemaSQL()
852
    {
853
        return ['ALTER INDEX idx_foo ON myschema.mytable RENAME TO idx_bar'];
854
    }
855
856
    /**
857
     * @group DBAL-807
858
     */
859
    protected function getQuotedAlterTableRenameIndexInSchemaSQL()
860
    {
861
        return [
862
            'ALTER INDEX "create" ON "schema"."table" RENAME TO "select"',
863
            'ALTER INDEX "foo" ON "schema"."table" RENAME TO "bar"',
864
        ];
865
    }
866
867
    /**
868
     * @group DBAL-423
869
     */
870
    public function testReturnsGuidTypeDeclarationSQL()
871
    {
872
        self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([]));
873
    }
874
875
    /**
876
     * {@inheritdoc}
877
     */
878
    public function getAlterTableRenameColumnSQL()
879
    {
880
        return ['ALTER TABLE foo RENAME bar TO baz'];
881
    }
882
883
    /**
884
     * {@inheritdoc}
885
     */
886
    protected function getQuotesTableIdentifiersInAlterTableSQL()
887
    {
888
        return [
889
            'ALTER TABLE "foo" DROP FOREIGN KEY fk1',
890
            'ALTER TABLE "foo" DROP FOREIGN KEY fk2',
891
            'ALTER TABLE "foo" RENAME id TO war',
892
            'ALTER TABLE "foo" ADD bloo INT NOT NULL, DROP baz, ALTER bar INT DEFAULT NULL',
893
            'ALTER TABLE "foo" RENAME "table"',
894
            'ALTER TABLE "table" ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)',
895
            'ALTER TABLE "table" ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)',
896
        ];
897
    }
898
899
    /**
900
     * {@inheritdoc}
901
     */
902
    protected function getCommentOnColumnSQL()
903
    {
904
        return [
905
            'COMMENT ON COLUMN foo.bar IS \'comment\'',
906
            'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'',
907
            'COMMENT ON COLUMN "select"."from" IS \'comment\'',
908
        ];
909
    }
910
911
    /**
912
     * @group DBAL-1004
913
     */
914
    public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers()
915
    {
916
        $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]);
917
        $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]);
918
919
        $comparator = new Comparator();
920
921
        $tableDiff = $comparator->diffTable($table1, $table2);
922
923
        self::assertInstanceOf(TableDiff::class, $tableDiff);
924
        self::assertSame(
925
            ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''],
926
            $this->platform->getAlterTableSQL($tableDiff)
0 ignored issues
show
Bug introduced by
It seems like $tableDiff can also be of type false; however, parameter $diff of Doctrine\DBAL\Platforms\...orm::getAlterTableSQL() does only seem to accept Doctrine\DBAL\Schema\TableDiff, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

926
            $this->platform->getAlterTableSQL(/** @scrutinizer ignore-type */ $tableDiff)
Loading history...
927
        );
928
    }
929
930
    /**
931
     * {@inheritdoc}
932
     */
933
    public function getReturnsForeignKeyReferentialActionSQL()
934
    {
935
        return [
936
            ['CASCADE', 'CASCADE'],
937
            ['SET NULL', 'SET NULL'],
938
            ['NO ACTION', 'RESTRICT'],
939
            ['RESTRICT', 'RESTRICT'],
940
            ['SET DEFAULT', 'SET DEFAULT'],
941
            ['CaScAdE', 'CASCADE'],
942
        ];
943
    }
944
945
    /**
946
     * {@inheritdoc}
947
     */
948
    protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL()
949
    {
950
        return 'CONSTRAINT "select" UNIQUE (foo)';
951
    }
952
953
    /**
954
     * {@inheritdoc}
955
     */
956
    protected function getQuotesReservedKeywordInIndexDeclarationSQL()
957
    {
958
        return ''; // not supported by this platform
959
    }
960
961
    /**
962
     * {@inheritdoc}
963
     */
964
    protected function getQuotesReservedKeywordInTruncateTableSQL()
965
    {
966
        return 'TRUNCATE TABLE "select"';
967
    }
968
969
    /**
970
     * {@inheritdoc}
971
     */
972
    protected function supportsInlineIndexDeclaration()
973
    {
974
        return false;
975
    }
976
977
    /**
978
     * {@inheritdoc}
979
     */
980
    protected function getAlterStringToFixedStringSQL()
981
    {
982
        return ['ALTER TABLE mytable ALTER name CHAR(2) NOT NULL'];
983
    }
984
985
    /**
986
     * {@inheritdoc}
987
     */
988
    protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
989
    {
990
        return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_foo_renamed'];
991
    }
992
993
    /**
994
     * @group DBAL-2436
995
     */
996
    public function testQuotesSchemaNameInListTableColumnsSQL()
997
    {
998
        self::assertContains(
999
            "'Foo''Bar\\'",
1000
            $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
1001
            '',
1002
            true
1003
        );
1004
    }
1005
1006
    /**
1007
     * @group DBAL-2436
1008
     */
1009
    public function testQuotesTableNameInListTableConstraintsSQL()
1010
    {
1011
        self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
1012
    }
1013
1014
    /**
1015
     * @group DBAL-2436
1016
     */
1017
    public function testQuotesSchemaNameInListTableConstraintsSQL()
1018
    {
1019
        self::assertContains(
1020
            "'Foo''Bar\\'",
1021
            $this->platform->getListTableConstraintsSQL("Foo'Bar\\.baz_table"),
1022
            '',
1023
            true
1024
        );
1025
    }
1026
1027
    /**
1028
     * @group DBAL-2436
1029
     */
1030
    public function testQuotesTableNameInListTableForeignKeysSQL()
1031
    {
1032
        self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
1033
    }
1034
1035
    /**
1036
     * @group DBAL-2436
1037
     */
1038
    public function testQuotesSchemaNameInListTableForeignKeysSQL()
1039
    {
1040
        self::assertContains(
1041
            "'Foo''Bar\\'",
1042
            $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
1043
            '',
1044
            true
1045
        );
1046
    }
1047
1048
    /**
1049
     * @group DBAL-2436
1050
     */
1051
    public function testQuotesTableNameInListTableIndexesSQL()
1052
    {
1053
        self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
1054
    }
1055
1056
    /**
1057
     * @group DBAL-2436
1058
     */
1059
    public function testQuotesSchemaNameInListTableIndexesSQL()
1060
    {
1061
        self::assertContains(
1062
            "'Foo''Bar\\'",
1063
            $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
1064
            '',
1065
            true
1066
        );
1067
    }
1068
}
1069