-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bizley
committed
Oct 29, 2018
1 parent
27b311f
commit 238cc74
Showing
5 changed files
with
111 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace bizley\tests\table; | ||
|
||
use bizley\migration\table\TableStructure; | ||
|
||
class TableStructureTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testRenderNameNoPrefix() | ||
{ | ||
$table = new TableStructure([ | ||
'name' => 'test', | ||
'usePrefix' => false, | ||
]); | ||
$this->assertEquals('test', $table->renderName()); | ||
} | ||
|
||
public function testRenderNameWithPrefix() | ||
{ | ||
$table = new TableStructure([ | ||
'name' => 'test', | ||
]); | ||
$this->assertEquals('{{%test}}', $table->renderName()); | ||
} | ||
|
||
public function testRenderNameWithPrefixAlreadyInName() | ||
{ | ||
$table = new TableStructure([ | ||
'name' => 'prefix_test', | ||
'dbPrefix' => 'prefix_', | ||
]); | ||
$this->assertEquals('{{%test}}', $table->renderName()); | ||
} | ||
|
||
public function testRenderTableCreate() | ||
{ | ||
$table = new TableStructure([ | ||
'name' => 'test', | ||
]); | ||
$this->assertEquals(" \$this->createTable('{{%test}}', [\n ]);\n", $table->renderTable()); | ||
} | ||
|
||
public function testRenderTableCreateDefaultTableOptions() | ||
{ | ||
$table = new TableStructure([ | ||
'name' => 'test', | ||
'tableOptionsInit' => '$tableOptions = null; | ||
if ($this->db->driverName === \'mysql\') { | ||
$tableOptions = \'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB\'; | ||
}', | ||
'tableOptions' => '$tableOptions', | ||
]); | ||
$this->assertEquals(" \$tableOptions = null;\n if (\$this->db->driverName === 'mysql') {\n \$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';\n }\n\n \$this->createTable('{{%test}}', [\n ], \$tableOptions);\n", $table->renderTable()); | ||
} | ||
} |