avoid duplication in return value when saving habtm

This commit is contained in:
Ceeram 2012-08-24 00:49:00 +02:00
parent c5ebbc991c
commit cb80338c7d
4 changed files with 3 additions and 3 deletions

View file

@ -1745,7 +1745,6 @@ class Model extends Object implements CakeEventListener {
if ($success && $count > 0) { if ($success && $count > 0) {
if (!empty($this->data)) { if (!empty($this->data)) {
$success = $this->data;
if ($created) { if ($created) {
$this->data[$this->alias][$this->primaryKey] = $this->id; $this->data[$this->alias][$this->primaryKey] = $this->id;
} }
@ -1755,7 +1754,7 @@ class Model extends Object implements CakeEventListener {
$this->getEventManager()->dispatch($event); $this->getEventManager()->dispatch($event);
} }
if (!empty($this->data)) { if (!empty($this->data)) {
$success = Hash::merge($success, $this->data); $success = $this->data;
} }
$this->data = false; $this->data = false;
$this->_clearCache(); $this->_clearCache();

View file

@ -888,6 +888,7 @@ class BehaviorCollectionTest extends CakeTestCase {
$Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test')); $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
$Sample->create(); $Sample->create();
$expected = $record; $expected = $record;
unset($expected['Sample']['name']);
$result = $Sample->save($record); $result = $Sample->save($record);
$expected['Sample']['id'] = $Sample->id; $expected['Sample']['id'] = $Sample->id;
$this->assertSame($expected, $result); $this->assertSame($expected, $result);

View file

@ -213,7 +213,6 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
'Armor' => array( 'Armor' => array(
'Armor' => array( 'Armor' => array(
1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4,
), ),
), ),
); );

View file

@ -1170,6 +1170,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$result = $TestModel->save(); $result = $TestModel->save();
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
$this->assertEquals($data['Tag'], $result['Tag']);
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment'))); $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
$result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2)));