Skip to content

Commit

Permalink
Adding tests for CURRENT_TIMESTAMP to DboSource.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 25, 2010
1 parent 59319b0 commit 5fcbc33
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo_source.test.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 5fcbc33

Please sign in to comment.