Skip to content
Permalink
Browse files

Added test for path amterialization in the eager loader

  • Loading branch information...
lorenzo committed Feb 4, 2014
1 parent 4840c96 commit 150880f9b977d261ba403c919feaafa5cc7ff9bb
Showing with 44 additions and 0 deletions.
  1. +44 −0 tests/TestCase/ORM/EagerLoaderTest.php
@@ -327,6 +327,50 @@ public function testContainToFieldsDefault() {
$this->assertEquals($expected, $select);
}
/**
* Tests that the path for gettings to a deep assocition is materialized in an
* array key
*
* @return void
*/
public function testNormalizedPath() {
$contains = [
'clients' => [
'orders' => [
'orderTypes',
'stuff' => ['stuffTypes']
],
'companies' => [
'categories'
]
]
];
$query = $this->getMock(
'\Cake\ORM\Query',
['join'],
[$this->connection, $this->table]
);
$loader = new EagerLoader;
$loader->contain($contains);
$normalized = $loader->normalized($this->table);
$this->assertEquals('clients', $normalized['clients']['path']);
$assocs = $normalized['clients']['associations'];
$this->assertEquals('clients.orders', $assocs['orders']['path']);
$assocs = $assocs['orders']['associations'];
$this->assertEquals('clients.orders.orderTypes', $assocs['orderTypes']['path']);
$this->assertEquals('clients.orders.stuff', $assocs['stuff']['path']);
$assocs = $assocs['stuff']['associations'];
$this->assertEquals(
'clients.orders.stuff.stuffTypes',
$assocs['stuffTypes']['path']
);
}
/**
* Helper function sued to quoted both keys and values in an array in case
* the test suite is running with auto quoting enabled

0 comments on commit 150880f

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