Skip to content
Permalink
Browse files

Adding tests for CURRENT_TIMESTAMP to DboSource.

  • Loading branch information...
markstory committed Jan 20, 2010
1 parent 59319b0 commit 5fcbc33a7566a5fe9eb12a384d36fb54e02aa9e5
Showing with 43 additions and 0 deletions.
  1. +43 −0 cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -3615,6 +3615,8 @@ function testBuildColumn() {
'default' => '',
'null' => false,
);
$restore = $this->testDb->columns;
$this->testDb->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), );
$result = $this->testDb->buildColumn($data);
$expected = '`int_field` int(11) NOT NULL';
@@ -3649,6 +3651,47 @@ function testBuildColumn() {
$result = $this->testDb->buildColumn($data);
$expected = '`int_field` int(11) COLLATE GOOD NOT NULL';
$this->assertEqual($result, $expected);
$this->testDb->columns = $restore;
$data = array(
'name' => 'created',
'type' => 'timestamp',
'default' => 'current_timestamp',
'null' => false,
);
$result = $this->db->buildColumn($data);
$expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL';
$this->assertEqual($result, $expected);
$data = array(
'name' => 'created',
'type' => 'timestamp',
'default' => 'CURRENT_TIMESTAMP',
'null' => true,
);
$result = $this->db->buildColumn($data);
$expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP';
$this->assertEqual($result, $expected);
$data = array(
'name' => 'modified',
'type' => 'timestamp',
'null' => true,
);
$result = $this->db->buildColumn($data);
$expected = '`modified` timestamp NULL';
$this->assertEqual($result, $expected);
$data = array(
'name' => 'modified',
'type' => 'timestamp',
'default' => null,
'null' => true,
);
$result = $this->db->buildColumn($data);
$expected = '`modified` timestamp NULL';
$this->assertEqual($result, $expected);
}
/**

0 comments on commit 5fcbc33

Please sign in to comment.
You can’t perform that action at this time.