public function testExportAllAndCache()
{
testpack('exportAll() and Cache');
$can = R::dispense('can')->setAttr('size', 3);
$can->ownCoffee[] = R::dispense('coffee')->setAttr('color', 'black');
$can->sharedTag[] = R::dispense('tag')->setAttr('name', 'cool');
$id = R::store($can);
R::debug(TRUE);
ob_start();
$can = R::load('can', $id);
$cache = $this->getCache();
$data = R::exportAll(array($can), TRUE);
$queries = ob_get_contents();
R::debug(FALSE);
ob_end_clean();
$len1 = strlen($queries);
$can = R::dispense('can')->setAttr('size', 3);
$can->ownCoffee[] = R::dispense('coffee')->setAttr('color', 'black');
$can->sharedTag[] = R::dispense('tag')->setAttr('name', 'cool');
$id = R::store($can);
R::debug(TRUE);
ob_start();
$can = R::load('can', $id);
$cache = $this->getCache();
$data = R::exportAll(array($can), TRUE);
$queries = ob_get_contents();
R::debug(FALSE);
ob_end_clean();
$len2 = strlen($queries);
asrt($len1, $len2);
$can = R::dispense('can')->setAttr('size', 3);
$can->ownCoffee[] = R::dispense('coffee')->setAttr('color', 'black');
$can->sharedTag[] = R::dispense('tag')->setAttr('name', 'cool');
$id = R::store($can);
R::debug(TRUE);
ob_start();
$can = R::load('can', $id);
$cache = $this->getCache();
R::getDuplicationManager()->setTables($cache);
$data = R::exportAll(array($can), TRUE);
$queries = ob_get_contents();
R::debug(FALSE);
ob_end_clean();
$len3 = strlen($queries);
asrt($len3 < $len2, TRUE);
asrt(count($data), 1);
asrt($data[0]['ownCoffee'][0]['color'], 'black');
R::getDuplicationManager()->setCacheTables(FALSE);
}