-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathViewsAsTablesSQLTest.php
More file actions
46 lines (40 loc) · 1.48 KB
/
ViewsAsTablesSQLTest.php
File metadata and controls
46 lines (40 loc) · 1.48 KB
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
<?php
namespace DBDiff\Tests\Unit;
use PHPUnit\Framework\TestCase;
use DBDiff\SQLGen\DiffToSQL\DropTableSQL;
use DBDiff\SQLGen\DiffToSQL\AddTableSQL;
use DBDiff\SQLGen\Dialect\MySQLDialect;
/**
* Tests that DropTableSQL and AddTableSQL generate correct SQL.
* The complement of this bug (#6) — views being treated as tables — is
* fixed at the adapter level (MySQLAdapter::getTables now uses
* SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'), which is covered
* by the integration test suite.
*
* These unit tests verify the SQL output classes still work correctly.
*/
class ViewsAsTablesSQLTest extends TestCase
{
public function testDropTableSQLGeneratesCorrectStatement(): void
{
$manager = $this->createMock(\DBDiff\DB\DBManager::class);
$obj = (object) [
'table' => 'old_table',
'manager' => $manager,
'connectionName' => 'target',
];
$sql = new DropTableSQL($obj, new MySQLDialect());
$this->assertSame('DROP TABLE `old_table`;', $sql->getUp());
}
public function testAddTableSQLDownGeneratesDropTable(): void
{
$manager = $this->createMock(\DBDiff\DB\DBManager::class);
$obj = (object) [
'table' => 'new_table',
'manager' => $manager,
'connectionName' => 'source',
];
$sql = new AddTableSQL($obj, new MySQLDialect());
$this->assertSame('DROP TABLE `new_table`;', $sql->getDown());
}
}