mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding test case to show how auto-computed fields should be removed from data if using to clone records, closes #6066
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8019 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f7dd0800d1
commit
b71457f332
1 changed files with 13 additions and 1 deletions
|
@ -994,6 +994,18 @@ class ModelTest extends CakeTestCase {
|
|||
$expected = array('Article' => array('published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text'));
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertFalse($TestModel->id);
|
||||
|
||||
$data = array('id' => 6, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text', 'created' => '1970-01-01 00:00:00', 'updated' => '1970-01-01 12:00:00', 'modified' => '1970-01-01 12:00:00');
|
||||
|
||||
$result = $TestModel->create($data);
|
||||
$expected = array('Article' => array('published' => 'N', 'id' => 6, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text', 'created' => '1970-01-01 00:00:00', 'updated' => '1970-01-01 12:00:00', 'modified' => '1970-01-01 12:00:00'));
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($TestModel->id, 6);
|
||||
|
||||
$result = $TestModel->create(array('Article' => array_diff_key($data, array('created' => true, 'updated' => true, 'modified' => true))), true);
|
||||
$expected = array('Article' => array('published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text'));
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertFalse($TestModel->id);
|
||||
}
|
||||
/**
|
||||
* testCreationWithMultipleData method
|
||||
|
@ -6456,4 +6468,4 @@ class ModelTest extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue