Skip to content

Commit

Permalink
Fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Apr 2, 2014
1 parent cf0f889 commit 8156305
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ORM/EntityValidator.php
Expand Up @@ -93,7 +93,8 @@ public function one(Entity $entity, $options = []) {
}

$validator = $association->target()->entityValidator();
if ($association->type() === Association::ONE_TO_ONE) {
$types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
if (in_array($association->type(), $types)) {
$valid = $validator->one($value, $assoc['options']) && $valid;
} else {
$valid = $validator->many($value, $assoc['options']) && $valid;
Expand Down
6 changes: 4 additions & 2 deletions src/ORM/Marshaller.php
Expand Up @@ -132,7 +132,8 @@ public function one(array $data, $include = []) {
protected function _marshalAssociation($assoc, $value, $include) {
$targetTable = $assoc->target();
$marshaller = $targetTable->marshaller();
if ($assoc->type() === Association::ONE_TO_ONE) {
$types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
if (in_array($assoc->type(), $types)) {
return $marshaller->one($value, (array)$include);
}
if ($assoc->type() === Association::MANY_TO_MANY) {
Expand Down Expand Up @@ -327,7 +328,8 @@ protected function _mergeAssociation($original, $assoc, $value, $include) {

$targetTable = $assoc->target();
$marshaller = $targetTable->marshaller();
if ($assoc->type() === Association::ONE_TO_ONE) {
$types = [Association::ONE_TO_ONE, Association::MANY_TO_ONE];
if (in_array($assoc->type(), $types)) {
return $marshaller->merge($original, $value, (array)$include);
}
if ($assoc->type() === Association::MANY_TO_MANY) {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -52,7 +52,7 @@ public function setUp() {
'\Cake\ORM\Association',
[
'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
'save', 'eagerLoader'
'save', 'eagerLoader', 'type'
],
['Foo', $config]
);
Expand Down

0 comments on commit 8156305

Please sign in to comment.