1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\DBAL\Platforms; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Platforms\MySQL57Platform; |
6
|
|
|
use Doctrine\DBAL\Types\Type; |
7
|
|
|
|
8
|
|
|
class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* {@inheritdoc} |
12
|
|
|
*/ |
13
|
|
|
public function createPlatform() |
14
|
|
|
{ |
15
|
|
|
return new MySQL57Platform(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testHasNativeJsonType() |
19
|
|
|
{ |
20
|
|
|
self::assertTrue($this->_platform->hasNativeJsonType()); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testReturnsJsonTypeDeclarationSQL() |
24
|
|
|
{ |
25
|
|
|
self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array())); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testInitializesJsonTypeMapping() |
29
|
|
|
{ |
30
|
|
|
self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json')); |
31
|
|
|
self::assertSame(Type::JSON, $this->_platform->getDoctrineTypeMapping('json')); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @group DBAL-234 |
36
|
|
|
*/ |
37
|
|
|
protected function getAlterTableRenameIndexSQL() |
38
|
|
|
{ |
39
|
|
|
return array( |
40
|
|
|
'ALTER TABLE mytable RENAME INDEX idx_foo TO idx_bar', |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @group DBAL-234 |
46
|
|
|
*/ |
47
|
|
|
protected function getQuotedAlterTableRenameIndexSQL() |
48
|
|
|
{ |
49
|
|
|
return array( |
50
|
|
|
'ALTER TABLE `table` RENAME INDEX `create` TO `select`', |
51
|
|
|
'ALTER TABLE `table` RENAME INDEX `foo` TO `bar`', |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @group DBAL-807 |
57
|
|
|
*/ |
58
|
|
|
protected function getAlterTableRenameIndexInSchemaSQL() |
59
|
|
|
{ |
60
|
|
|
return array( |
61
|
|
|
'ALTER TABLE myschema.mytable RENAME INDEX idx_foo TO idx_bar', |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @group DBAL-807 |
67
|
|
|
*/ |
68
|
|
|
protected function getQuotedAlterTableRenameIndexInSchemaSQL() |
69
|
|
|
{ |
70
|
|
|
return array( |
71
|
|
|
'ALTER TABLE `schema`.`table` RENAME INDEX `create` TO `select`', |
72
|
|
|
'ALTER TABLE `schema`.`table` RENAME INDEX `foo` TO `bar`', |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() |
80
|
|
|
{ |
81
|
|
|
return array( |
82
|
|
|
'ALTER TABLE mytable RENAME INDEX idx_foo TO idx_foo_renamed', |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @group DBAL-2576 |
88
|
|
|
*/ |
89
|
|
|
public function testNotDuplicateDropForeignKeySql() |
90
|
|
|
{ |
91
|
|
|
$diff = $this->createNotDuplicateDropForeignKeySql(); |
92
|
|
|
|
93
|
|
|
// Run through alter table method |
94
|
|
|
$sql = $this->_platform->getAlterTableSQL($diff); |
95
|
|
|
|
96
|
|
|
// Assert that there are no duplicates in the results |
97
|
|
|
$this->assertSame(array( |
98
|
|
|
'ALTER TABLE documents DROP FOREIGN KEY documents_ibfk_1', |
99
|
|
|
'ALTER TABLE documents ADD CONSTRAINT FK_a788692ffa0c224 FOREIGN KEY (office_id) REFERENCES offices (id) ON DELETE CASCADE', |
100
|
|
|
'ALTER TABLE documents RENAME INDEX office_id TO IDX_A788692FFA0C224' |
101
|
|
|
), $sql); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|