Skip to content

Commit

Permalink
Ref #16575 - Add tests to cover the DEFAULT timestamp support
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Feb 16, 2021
1 parent 88752d6 commit 9754d16
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions test/classes/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,84 @@ public function testGenerateFieldSpec(): void
$query
);

$type = 'TIMESTAMP';
$length = '';
$extra = '';
$default_type = 'USER_DEFINED';
$default_value = '\'0000-00-00 00:00:00\'';
$query = Table::generateFieldSpec(
$name,
$type,
$length,
$attribute,
$collation,
$null,
$default_type,
$default_value,
$extra,
$comment,
$virtuality,
$expression,
$move_to
);
$this->assertEquals(
'`PMA_name` TIMESTAMP PMA_attribute NULL DEFAULT \'0000-00-00 00:00:00\' '
. "COMMENT 'PMA_comment' FIRST",
$query
);

$type = 'TIMESTAMP';
$length = '';
$extra = '';
$default_type = 'USER_DEFINED';
$default_value = '\'0000-00-00 00:00:00.0\'';
$query = Table::generateFieldSpec(
$name,
$type,
$length,
$attribute,
$collation,
$null,
$default_type,
$default_value,
$extra,
$comment,
$virtuality,
$expression,
$move_to
);
$this->assertEquals(
'`PMA_name` TIMESTAMP PMA_attribute NULL DEFAULT \'0000-00-00 00:00:00.0\' '
. "COMMENT 'PMA_comment' FIRST",
$query
);

$type = 'TIMESTAMP';
$length = '';
$extra = '';
$default_type = 'USER_DEFINED';
$default_value = '\'0000-00-00 00:00:00.000000\'';
$query = Table::generateFieldSpec(
$name,
$type,
$length,
$attribute,
$collation,
$null,
$default_type,
$default_value,
$extra,
$comment,
$virtuality,
$expression,
$move_to
);
$this->assertEquals(
'`PMA_name` TIMESTAMP PMA_attribute NULL DEFAULT \'0000-00-00 00:00:00.000000\' '
. "COMMENT 'PMA_comment' FIRST",
$query
);

//$default_type is NONE
$type = 'BOOLEAN';
$default_type = 'NONE';
Expand Down

0 comments on commit 9754d16

Please sign in to comment.