Skip to content

Commit

Permalink
Refactor tests + add test for just change in def expression - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SOHELAHMED7 committed Jan 23, 2023
1 parent 8e238a9 commit 3bdfd00
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/unit/XDbDefaultExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function testEditExpression()

private function createTablesForEditExpression()
{
Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
$mysqlColumns = [
'ts' => 'datetime DEFAULT \'2011-11-11 00:00:00\'',
'ts2' => 'datetime DEFAULT CURRENT_TIMESTAMP',
'ts3' => 'datetime DEFAULT CURRENT_TIMESTAMP',
Expand All @@ -191,7 +191,15 @@ private function createTablesForEditExpression()
'd' => 'date DEFAULT \'2011-11-11\'',
'd2' => 'text', // DEFAULT "2011-11-11"
'd3' => 'text', // DEFAULT CURRENT_DATE + INTERVAL 1 YEAR
'ts7' => 'date DEFAULT \'2011-11-11\'',
])->execute();
'ts7' => 'date DEFAULT (CURRENT_DATE + INTERVAL 2 YEAR)',
];
if (ApiGenerator::isPostgres()) {
$pgsqlColumns = $mysqlColumns;
$pgsqlColumns['ts7'] = 'date DEFAULT (CURRENT_DATE + INTERVAL \'2 YEAR\')';
Yii::$app->db->createCommand()->createTable('{{%fruits}}', $pgsqlColumns)->execute();
return;
}

Yii::$app->db->createCommand()->createTable('{{%fruits}}', $mysqlColumns)->execute();
}
}

0 comments on commit 3bdfd00

Please sign in to comment.