From 5fcbc33a7566a5fe9eb12a384d36fb54e02aa9e5 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 19 Jan 2010 23:55:50 -0500 Subject: [PATCH] Adding tests for CURRENT_TIMESTAMP to DboSource. --- .../model/datasources/dbo_source.test.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 0bd4a52b4ca..642ad8911d4 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/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); } /**