Skip to content

Commit 5fcbc33

Browse files
committed
Adding tests for CURRENT_TIMESTAMP to DboSource.
1 parent 59319b0 commit 5fcbc33

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

cake/tests/cases/libs/model/datasources/dbo_source.test.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,8 @@ function testBuildColumn() {
36153615
'default' => '',
36163616
'null' => false,
36173617
);
3618+
$restore = $this->testDb->columns;
3619+
36183620
$this->testDb->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), );
36193621
$result = $this->testDb->buildColumn($data);
36203622
$expected = '`int_field` int(11) NOT NULL';
@@ -3649,6 +3651,47 @@ function testBuildColumn() {
36493651
$result = $this->testDb->buildColumn($data);
36503652
$expected = '`int_field` int(11) COLLATE GOOD NOT NULL';
36513653
$this->assertEqual($result, $expected);
3654+
3655+
$this->testDb->columns = $restore;
3656+
3657+
$data = array(
3658+
'name' => 'created',
3659+
'type' => 'timestamp',
3660+
'default' => 'current_timestamp',
3661+
'null' => false,
3662+
);
3663+
$result = $this->db->buildColumn($data);
3664+
$expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL';
3665+
$this->assertEqual($result, $expected);
3666+
3667+
$data = array(
3668+
'name' => 'created',
3669+
'type' => 'timestamp',
3670+
'default' => 'CURRENT_TIMESTAMP',
3671+
'null' => true,
3672+
);
3673+
$result = $this->db->buildColumn($data);
3674+
$expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP';
3675+
$this->assertEqual($result, $expected);
3676+
3677+
$data = array(
3678+
'name' => 'modified',
3679+
'type' => 'timestamp',
3680+
'null' => true,
3681+
);
3682+
$result = $this->db->buildColumn($data);
3683+
$expected = '`modified` timestamp NULL';
3684+
$this->assertEqual($result, $expected);
3685+
3686+
$data = array(
3687+
'name' => 'modified',
3688+
'type' => 'timestamp',
3689+
'default' => null,
3690+
'null' => true,
3691+
);
3692+
$result = $this->db->buildColumn($data);
3693+
$expected = '`modified` timestamp NULL';
3694+
$this->assertEqual($result, $expected);
36523695
}
36533696

36543697
/**

0 commit comments

Comments
 (0)