Skip to content
Permalink
Browse files

Fix up contain() to be BC with key value contains.

  • Loading branch information...
dereuromark committed Feb 10, 2017
1 parent 6c0f373 commit 46f1af7320a6e959bb97a55b1a29e51bf2777316
Showing with 28 additions and 0 deletions.
  1. +4 −0 src/ORM/EagerLoader.php
  2. +24 −0 tests/TestCase/ORM/EagerLoaderTest.php
@@ -389,6 +389,10 @@ protected function _reformatContain($associations, $original)
};
}
if (!is_array($options)) {
$options = [$options => []];
}
$pointer[$table] = $options + $pointer[$table];
}
@@ -276,6 +276,30 @@ public function testContainDotNotation()
$this->assertEquals($expected, $loader->contain());
}
/**
* Tests setting containments using direct key value pairs works just as with key array.
*
* @return void
*/
public function testContainKeyValueNotation()
{
$loader = new EagerLoader;
$loader->contain([
'clients',
'companies' => 'categories',
]);
$expected = [
'clients' => [
],
'companies' => [
'categories' => [
],
],
];
$this->assertEquals($expected, $loader->contain());
}
/**
* Tests that it is possible to pass a function as the array value for contain
*

0 comments on commit 46f1af7

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