Skip to content

Commit

Permalink
#11 - Change RunCest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Mar 22, 2020
1 parent f0a0a22 commit 630c8e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private static function connectionSetup(array $options): void
self::$storage = new $adapter($configArray);

if ($database->adapter === 'Mysql') {
//self::$storage->query('SET FOREIGN_KEY_CHECKS=0');
self::$storage->query('SET FOREIGN_KEY_CHECKS=0');
}

if (!self::$storage->tableExists(self::MIGRATION_LOG_TABLE)) {
Expand Down
16 changes: 8 additions & 8 deletions tests/cli/RunCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function skipForeignKeys(CliTester $I): void
$table1 = 'client';
$table2 = 'x-skip-foreign-keys';

$this->createTablesWithForeignKey($I);
$this->createTablesWithForeignKey($I, $table1, $table2);

$I->runShellCommand('php phalcon-migrations generate --config=' . $this->configPath);
$I->seeInShellOutput('Success: Version 1.0.0 was successfully generated');
Expand All @@ -91,17 +91,17 @@ public function skipForeignKeys(CliTester $I): void
*/
public function expectForeignKeyDbError(CliTester $I): void
{
$table1 = 'client';
$table2 = 'x-skip-foreign-keys';
$table1 = 'z-client';
$table2 = 'skip-foreign-keys';

$this->createTablesWithForeignKey($I);
$this->createTablesWithForeignKey($I, $table1, $table2);

$I->runShellCommand('php phalcon-migrations generate --config=' . $this->configPath);
$I->seeInShellOutput('Success: Version 1.0.0 was successfully generated');
$I->seeResultCodeIs(0);

$migrationContent = file_get_contents(codecept_output_dir('1.0.0/' . $table2 . '.php'));
$I->assertNotFalse(strpos($migrationContent, "'referencedTable' => 'client',"));
$I->assertNotFalse(strpos($migrationContent, "'referencedTable' => '" . $table1 . "',"));

$I->getPhalconDb()->dropTable($table2);
$I->getPhalconDb()->dropTable($table1);
Expand All @@ -115,12 +115,12 @@ public function expectForeignKeyDbError(CliTester $I): void
* DRY!
*
* @param CliTester $I
* @param string $table1
* @param string $table2
*/
protected function createTablesWithForeignKey(CliTester $I): void
protected function createTablesWithForeignKey(CliTester $I, string $table1, string $table2): void
{
$schema = getenv('MYSQL_TEST_DB_DATABASE');
$table1 = 'client';
$table2 = 'x-skip-foreign-keys';

$I->getPhalconDb()->createTable($table1, $schema, [
'columns' => [
Expand Down

0 comments on commit 630c8e2

Please sign in to comment.