Skip to content
Permalink
Browse files

fix incorrect tests

  • Loading branch information...
ceeram committed Nov 2, 2012
1 parent b8607ca commit b18550c6675cddfcf47cb5b774d802c8c0f61738
Showing with 48 additions and 7 deletions.
  1. +48 −7 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -6642,18 +6642,59 @@ public function testSaveAllFieldListHasOne() {
));
$this->assertTrue($result);
$this->assertEmpty($TestModel->validationErrors);
}
/**
* testSaveAllFieldListHasOneAddFkToWhitelist method
*
* @return void
*/
public function testSaveAllFieldListHasOneAddFkToWhitelist() {
$this->loadFixtures('ArticleFeatured', 'Featured');
$Article = new ArticleFeatured();
$Article->belongsTo = $Article->hasMany = array();
$Article->Featured->validate = array('end_date' => 'notEmpty');
$record = array(
'ArticleFeatured' => array(
'user_id' => 1,
'title' => 'First Article',
'body' => '',
'published' => 'Y'
),
'Featured' => array(
'category_id' => 1,
'end_date' => ''
)
);
$result = $Article->saveAll($record, array('validate' => 'only'));
$this->assertFalse($result);
$expected = array(
'body' => array(
'This field cannot be left blank'
),
'Featured' => array(
'end_date' => array(
'This field cannot be left blank'
)
)
);
$this->assertEquals($expected, $Article->validationErrors);
$TestModel->Attachment->whitelist = array('id');
$fieldList = array(
'Comment' => array('id', 'article_id', 'user_id'),
'Attachment' => array('id')
'ArticleFeatured' => array('user_id', 'title'),
'Featured' => array('category_id')
);
$result = $TestModel->saveAll($record, array(
'fieldList' => $fieldList
$result = $Article->saveAll($record, array(
'fieldList' => $fieldList, 'validate' => 'first'
));
$this->assertTrue($result);
$result = $TestModel->find('first', array('order' => array('Comment.created' => 'DESC')));
$this->assertEquals($result['Comment']['id'], $result['Attachment']['comment_id']);
$this->assertEmpty($Article->validationErrors);
$Article->recursive = 0;
$result = $Article->find('first', array('order' => array('ArticleFeatured.created' => 'DESC')));
$this->assertSame($result['ArticleFeatured']['id'], $result['Featured']['article_featured_id']);
}
/**

0 comments on commit b18550c

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