Skip to content
Permalink
Browse files

Adding test for fieldList when mergind associations

  • Loading branch information...
lorenzo committed Jul 12, 2014
1 parent 8adcacf commit 86c10b323968f0bd029516b16aae8d203d5c9988
Showing with 39 additions and 0 deletions.
  1. +39 −0 tests/TestCase/ORM/MarshallerTest.php
@@ -1114,4 +1114,43 @@ public function testAssociatoinsFieldList() {
$this->assertNull($result->user->password);
}
/**
* Tests merging data into an associated entity
*
* @return void
*/
public function testMergeAssociationWithfieldList() {
$user = new Entity([
'username' => 'mark',
'password' => 'secret'
]);
$entity = new Entity([
'tile' => 'My Title',
'user' => $user
]);
$user->accessible('*', true);
$entity->accessible('*', true);
$data = [
'body' => 'My Content',
'something' => 'else',
'user' => [
'password' => 'not a secret',
'extra' => 'data'
]
];
$marshall = new Marshaller($this->articles);
$marshall->merge($entity, $data, [
'fieldList' => ['something'],
'associated' => ['Users' => ['fieldList' => ['extra']]]
]);
$this->assertNull($entity->body);
$this->assertEquals('else', $entity->something);
$this->assertSame($user, $entity->user);
$this->assertEquals('mark', $entity->user->username);
$this->assertEquals('secret', $entity->user->password);
$this->assertEquals('data', $entity->user->extra);
$this->assertTrue($entity->dirty('user'));
}
}

0 comments on commit 86c10b3

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