Skip to content

Commit

Permalink
Fixing some broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 9, 2014
1 parent c5ae11b commit aea75b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/ORM/Table.php
Expand Up @@ -1597,7 +1597,7 @@ public function newEntity(array $data = [], array $options = []) {
*
* By default all the associations on this table will be hydrated. You can
* limit which associations are built, or include deeper associations
* using the associations parameter:
* using the options parameter:
*
* {{{
* $articles = $this->Articles->newEntities(
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public function patchEntity(EntityInterface $entity, array $data, array $options
$options['associated'] = $this->_associations->keys();
}
$marshaller = $this->marshaller();
return $marshaller->merge($entity, $data, $associations);
return $marshaller->merge($entity, $data, $options);
}

/**
Expand Down
38 changes: 19 additions & 19 deletions tests/TestCase/ORM/MarshallerTest.php
Expand Up @@ -202,7 +202,7 @@ public function testOneWithAdditionalName() {
]
];
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['Users']);
$result = $marshall->one($data, ['associated' => ['Users']]);

$this->assertInstanceOf('Cake\ORM\Entity', $result);
$this->assertTrue($result->dirty(), 'Should be a dirty entity.');
Expand Down Expand Up @@ -231,7 +231,7 @@ public function testOneAssociationsSingle() {
]
];
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['Users']);
$result = $marshall->one($data, ['associated' => ['Users']]);

$this->assertEquals($data['title'], $result->title);
$this->assertEquals($data['body'], $result->body);
Expand Down Expand Up @@ -265,7 +265,7 @@ public function testOneAssociationsMany() {
]
];
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['Comments']);
$result = $marshall->one($data, ['associated' => ['Comments']]);

$this->assertEquals($data['title'], $result->title);
$this->assertEquals($data['body'], $result->body);
Expand Down Expand Up @@ -298,7 +298,7 @@ public function testOneBelongsToManyJoinData() {
];
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, [
'Tags'
'associated' => ['Tags']
]);

$this->assertEquals($data['title'], $result->title);
Expand Down Expand Up @@ -352,7 +352,7 @@ public function testOneBelongsToManyJoinDataAssociated() {
$articlesTags->belongsTo('Users');

$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['Tags._joinData.Users']);
$result = $marshall->one($data, ['associated' => ['Tags._joinData.Users']]);
$this->assertInstanceOf(
'Cake\ORM\Entity',
$result->tags[0]->_joinData->user,
Expand Down Expand Up @@ -386,7 +386,7 @@ public function testOneDeepAssociations() {
]
];
$marshall = new Marshaller($this->comments);
$result = $marshall->one($data, ['Articles.Users']);
$result = $marshall->one($data, ['associated' => ['Articles.Users']]);

$this->assertEquals(
$data['article']['title'],
Expand Down Expand Up @@ -441,7 +441,7 @@ public function testManyAssociations() {
],
];
$marshall = new Marshaller($this->comments);
$result = $marshall->many($data, ['Users']);
$result = $marshall->many($data, ['associated' => ['Users']]);

$this->assertCount(2, $result);
$this->assertInstanceOf('Cake\ORM\Entity', $result[0]);
Expand All @@ -468,23 +468,23 @@ public function testOneGenerateBelongsToManyEntitiesFromIds() {
'tags' => ['_ids' => '']
];
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['Tags']);
$result = $marshall->one($data, ['associated' => ['Tags']]);
$this->assertCount(0, $result->tags);

$data = [
'title' => 'Haz tags',
'body' => 'Some content here',
'tags' => ['_ids' => false]
];
$result = $marshall->one($data, ['Tags']);
$result = $marshall->one($data, ['associated' => ['Tags']]);
$this->assertCount(0, $result->tags);

$data = [
'title' => 'Haz tags',
'body' => 'Some content here',
'tags' => ['_ids' => null]
];
$result = $marshall->one($data, ['Tags']);
$result = $marshall->one($data, ['associated' => ['Tags']]);
$this->assertCount(0, $result->tags);

$data = [
Expand All @@ -493,7 +493,7 @@ public function testOneGenerateBelongsToManyEntitiesFromIds() {
'tags' => ['_ids' => [1, 2, 3]]
];
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['Tags']);
$result = $marshall->one($data, ['associated' => ['Tags']]);

$this->assertCount(3, $result->tags);
$this->assertInstanceOf('Cake\ORM\Entity', $result->tags[0]);
Expand Down Expand Up @@ -612,7 +612,7 @@ public function testMergeWithSingleAssociation() {
]
];
$marshall = new Marshaller($this->articles);
$marshall->merge($entity, $data, ['Users']);
$marshall->merge($entity, $data, ['associated' => ['Users']]);
$this->assertEquals('My Content', $entity->body);
$this->assertSame($user, $entity->user);
$this->assertEquals('mark', $entity->user->username);
Expand All @@ -639,7 +639,7 @@ public function testMergeCreateAssociation() {
]
];
$marshall = new Marshaller($this->articles);
$marshall->merge($entity, $data, ['Users']);
$marshall->merge($entity, $data, ['associated' => ['Users']]);
$this->assertEquals('My Content', $entity->body);
$this->assertInstanceOf('Cake\ORM\Entity', $entity->user);
$this->assertEquals('mark', $entity->user->username);
Expand Down Expand Up @@ -680,7 +680,7 @@ public function testMergeMultipleAssociations() {
]
];
$marshall = new Marshaller($this->articles);
$result = $marshall->merge($entity, $data, ['Users', 'Comments']);
$result = $marshall->merge($entity, $data, ['associated' => ['Users', 'Comments']]);
$this->assertSame($entity, $result);
$this->assertSame($user, $result->user);
$this->assertEquals('not so secret', $entity->user->password);
Expand Down Expand Up @@ -724,7 +724,7 @@ public function testMergeBelongsToManyEntitiesFromIds() {
];
$entity->accessible('*', true);
$marshall = new Marshaller($this->articles);
$result = $marshall->merge($entity, $data, ['Tags']);
$result = $marshall->merge($entity, $data, ['associated' => ['Tags']]);

$this->assertCount(3, $result->tags);
$this->assertInstanceOf('Cake\ORM\Entity', $result->tags[0]);
Expand Down Expand Up @@ -754,21 +754,21 @@ public function testMergeBelongsToManyEntitiesFromIdsEmptyValue() {
];
$entity->accessible('*', true);
$marshall = new Marshaller($this->articles);
$result = $marshall->merge($entity, $data, ['Tags']);
$result = $marshall->merge($entity, $data, ['associated' => ['Tags']]);
$this->assertCount(0, $result->tags);

$data = [
'title' => 'Haz moar tags',
'tags' => ['_ids' => false]
];
$result = $marshall->merge($entity, $data, ['Tags']);
$result = $marshall->merge($entity, $data, ['associated' => ['Tags']]);
$this->assertCount(0, $result->tags);

$data = [
'title' => 'Haz moar tags',
'tags' => ['_ids' => null]
];
$result = $marshall->merge($entity, $data, ['Tags']);
$result = $marshall->merge($entity, $data, ['associated' => ['Tags']]);
$this->assertCount(0, $result->tags);
}

Expand Down Expand Up @@ -864,7 +864,7 @@ public function testMergeJoinDataAssociations() {
$articlesTags = TableRegistry::get('ArticlesTags');
$articlesTags->belongsTo('Users');

$options = ['Tags._joinData.Users'];
$options = ['associated' => ['Tags._joinData.Users']];
$marshall = new Marshaller($this->articles);
$entity = $marshall->one($data, $options);
$entity->accessible('*', true);
Expand Down

0 comments on commit aea75b9

Please sign in to comment.