Skip to content
Permalink
Browse files

Fixing some broken tests

  • Loading branch information...
lorenzo committed Jul 9, 2014
1 parent c5ae11b commit aea75b949849cf4a13fa68bb0acd97e24e70980b
Showing with 21 additions and 21 deletions.
  1. +2 −2 src/ORM/Table.php
  2. +19 −19 tests/TestCase/ORM/MarshallerTest.php
@@ -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(
@@ -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);
}
/**
@@ -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.');
@@ -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);
@@ -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);
@@ -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);
@@ -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,
@@ -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'],
@@ -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]);
@@ -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 = [
@@ -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]);
@@ -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);
@@ -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);
@@ -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);
@@ -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]);
@@ -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);
}
@@ -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);

0 comments on commit aea75b9

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