Skip to content

Commit

Permalink
Fixing a couple of problem when testing dates in ModelWriteTest
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Oct 5, 2011
1 parent ecb63d9 commit 746062d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Expand Up @@ -3322,10 +3322,10 @@ public function testSaveAllValidation() {
'author_id' => 2
));

$ts = date('Y-m-d H:i:s');
$this->assertTrue($TestModel->saveAll($data));

$result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC'));
$ts = date('Y-m-d H:i:s');
$expected = array(
array(
'Post' => array(
Expand All @@ -3334,8 +3334,7 @@ public function testSaveAllValidation() {
'title' => 'Baleeted First Post',
'body' => 'Baleeted!',
'published' => 'N',
'created' => '2007-03-18 10:39:23',
'updated' => $ts
'created' => '2007-03-18 10:39:23'
)),
array(
'Post' => array(
Expand All @@ -3344,7 +3343,7 @@ public function testSaveAllValidation() {
'title' => 'Just update the title',
'body' => 'Second Post Body',
'published' => 'Y',
'created' => '2007-03-18 10:41:23', 'updated' => $ts
'created' => '2007-03-18 10:41:23'
)),
array(
'Post' => array(
Expand All @@ -3366,6 +3365,9 @@ public function testSaveAllValidation() {
'created' => $ts,
'updated' => $ts
)));
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
unset($result[0]['Post']['updated'], $result[1]['Post']['updated']);
$this->assertEqual($expected, $result);

$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
Expand Down Expand Up @@ -3407,11 +3409,11 @@ public function testSaveAllValidation() {
'title' => '',
'body' => 'Trying to get away with an empty title'
));
$newTs = date('Y-m-d H:i:s');
$result = $TestModel->saveAll($data, array('validate' => true, 'atomic' => false));
$this->assertEqual($result, array(true, false));
$result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC'));
$errors = array(1 => array('title' => array('This field cannot be left blank')));
$newTs = date('Y-m-d H:i:s');
$expected = array(
array(
'Post' => array(
Expand Down

0 comments on commit 746062d

Please sign in to comment.