Browse Source

Fixed more Marshaller tests

Jose Lorenzo Rodriguez 11 years ago
parent
commit
eaa62ee1ca

+ 4 - 3
src/ORM/Marshaller.php

@@ -110,7 +110,7 @@ class Marshaller {
 			$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 @@ class Marshaller {
  * @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 @@ class Marshaller {
 		$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) {

+ 2 - 2
tests/TestCase/ORM/CompositeKeysTest.php

@@ -444,7 +444,7 @@ class CompositeKeyTest extends TestCase {
 			'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 @@ class CompositeKeyTest extends TestCase {
 			'tags' => ['_ids' => [1, 2, 3]]
 		];
 		$marshall = new Marshaller($articles);
-		$result = $marshall->one($data, ['SiteTags']);
+		$result = $marshall->one($data, ['associated' => ['SiteTags']]);
 		$this->assertEmpty($result->tags);
 	}
 

+ 1 - 1
tests/TestCase/ORM/MarshallerTest.php

@@ -800,7 +800,7 @@ class MarshallerTest extends TestCase {
 			],
 		];
 
-		$options = ['Tags' => ['associated' => ['_joinData']]];
+		$options = ['associated' => ['Tags' => ['associated' => ['_joinData']]]];
 		$marshall = new Marshaller($this->articles);
 		$entity = $marshall->one($data, $options);
 		$entity->accessible('*', true);