Skip to content
Permalink
Browse files

Fixed more Marshaller tests

  • Loading branch information...
lorenzo committed Jul 10, 2014
1 parent aea75b9 commit eaa62ee1ca66de994e23ff1107549aa98e7caca2
Showing with 7 additions and 6 deletions.
  1. +4 −3 src/ORM/Marshaller.php
  2. +2 −2 tests/TestCase/ORM/CompositeKeysTest.php
  3. +1 −1 tests/TestCase/ORM/MarshallerTest.php
@@ -110,7 +110,7 @@ public function one(array $data, array $options = []) {
$columnType = $schema->columnType($key);
if (isset($propertyMap[$key])) {
$assoc = $propertyMap[$key]['association'];
$nested = $propertyMap[$key]['nested'];
$nested = ['associated' => $propertyMap[$key]['nested']];
$value = $this->_marshalAssociation($assoc, $value, $nested);
} elseif ($columnType) {
$converter = Type::build($columnType);
@@ -172,6 +172,7 @@ public function many(array $data, array $options = []) {
* @return array An array of built entities.
*/
protected function _belongsToMany(Association $assoc, array $data, $options = []) {
$associated = isset($options['associated']) ? $options['associated'] : [];
$hasIds = array_key_exists('_ids', $data);
if ($hasIds && is_array($data['_ids'])) {
return $this->_loadBelongsToMany($assoc, $data['_ids']);
@@ -185,8 +186,8 @@ protected function _belongsToMany(Association $assoc, array $data, $options = []
$jointMarshaller = $joint->marshaller();
$nested = [];
if (isset($options['_joinData']['associated'])) {
$nested = (array)$options['_joinData']['associated'];
if (isset($associated['_joinData']['associated'])) {
$nested = ['associated' => (array)$associated['_joinData']['associated']];
}
foreach ($records as $i => $record) {
@@ -444,7 +444,7 @@ public function testOneGenerateBelongsToManyEntitiesFromIds() {
'tags' => ['_ids' => [[1, 1], [2, 2], [3, 1]]]
];
$marshall = new Marshaller($articles);
$result = $marshall->one($data, ['SiteTags']);
$result = $marshall->one($data, ['associated' => ['SiteTags']]);
$this->assertCount(3, $result->tags);
$this->assertInstanceOf('Cake\ORM\Entity', $result->tags[0]);
@@ -457,7 +457,7 @@ public function testOneGenerateBelongsToManyEntitiesFromIds() {
'tags' => ['_ids' => [1, 2, 3]]
];
$marshall = new Marshaller($articles);
$result = $marshall->one($data, ['SiteTags']);
$result = $marshall->one($data, ['associated' => ['SiteTags']]);
$this->assertEmpty($result->tags);
}
@@ -800,7 +800,7 @@ public function testMergeBelongsToManyJoinData() {
],
];
$options = ['Tags' => ['associated' => ['_joinData']]];
$options = ['associated' => ['Tags' => ['associated' => ['_joinData']]]];
$marshall = new Marshaller($this->articles);
$entity = $marshall->one($data, $options);
$entity->accessible('*', true);

0 comments on commit eaa62ee

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