/** * @dataProvider getAdaptersTestData */ public function testGetAllInReversedOrder(Adapter\AdapterInterface $adapter) { $fs = $this->buildFs(); $collection = $this->buildCollection($adapter, $fs->getRoot() . DIRECTORY_SEPARATOR . 'Canon_450D'); $tree = $fs->getTree(); $expected = array_keys($tree['Canon_450D']); sort($expected); foreach ($collection->sort(SortHelper::reverseName())->getAll() as $set) { $results[] = $set->name; } $this->array(array_reverse($expected))->isEqualTo($results); }
/** * @dataProvider getAdaptersTestData */ public function testGetInReversedOrder(Adapter\AdapterInterface $adapter) { $set = $this->buildSet($adapter); $tree = $this->buildFs()->getTree(); $expected = $tree['Travels']['Chile']; array_pop($expected); sort($expected); foreach ($set->sort(SortHelper::reverseName())->getAll() as $file) { $results[] = $file->getFilename(); } $this->array(array_reverse($expected))->isEqualTo($results); }
// Deletes the cached file @unlink($cache); // Flushes the application HTTP cache for the current URI $app['http_cache']->getStore()->invalidate($app['request']); } }); $app['portfolio.template_http_cache_helper'] = $app->protect(function ($template_name) use($app) { $template_abspath = $app['twig.content_path'] . DIRECTORY_SEPARATOR . $template_name; $cache_headers['Last-Modified'] = date('r', filemtime($template_abspath)); }); // This closure is the core of the application. It fetch all sets and order them in the right way $app['smak.portfolio.set_provider'] = $app->protect(function () use($app) { // Result set $results = array(); // Gets sets $sets = $app['smak.portfolio']->name($app['smak.portfolio.gallery_pattern'])->sort(SortHelper::reverseName())->getAll(); // Return false is there is nothing to show if (empty($sets)) { return null; } // If the debug mod is disabled or and sets are already in session if (!$app['debug'] && $app['session']->has('smak.portfolio.sets')) { $session_sets = $app['session']->get('smak.portfolio.sets'); if (count($sets) == count($session_sets)) { return $session_sets; } } clearstatcache(); while ($sets->valid()) { $set = $sets->current(); $smak_template = $set->getTemplate();