diff --git a/Command/ResolveCacheCommand.php b/Command/ResolveCacheCommand.php index 7e32a6bb7..81ff0c7b7 100644 --- a/Command/ResolveCacheCommand.php +++ b/Command/ResolveCacheCommand.php @@ -21,6 +21,28 @@ protected function configure() 'f', InputOption::VALUE_OPTIONAL|InputOption::VALUE_IS_ARRAY, 'Filters list' + )->setHelp(<<%command.name% command resolves cache by specified parameters. +It returns list of urls. + +php app/console %command.name% path1 path2 --filters=thumb1 +Cache for this two paths will be resolved with passed filter. +As a result you will get + http://localhost/media/cache/thumb1/path1 + http://localhost/media/cache/thumb1/path2 + +You can pass few filters: +php app/console %command.name% path1 --filters=thumb1 --filters=thumb2 +As a result you will get + http://localhost/media/cache/thumb1/path1 + http://localhost/media/cache/thumb2/path1 + +If you omit --filters parameter then to resolve given paths will be used all configured and available filters in application: +php app/console %command.name% path1 +As a result you will get + http://localhost/media/cache/thumb1/path1 + http://localhost/media/cache/thumb2/path1 +EOF ); } diff --git a/Tests/Functional/Command/ResolveCacheTest.php b/Tests/Functional/Command/ResolveCacheTest.php index a6d254ad5..c18a9acc7 100644 --- a/Tests/Functional/Command/ResolveCacheTest.php +++ b/Tests/Functional/Command/ResolveCacheTest.php @@ -33,18 +33,19 @@ public function setUp() $this->filesystem->remove($this->cacheRoot); } - public function testShouldResolveWithEmptyCache() { $this->assertFileNotExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); $output = $this->executeConsole( new ResolveCacheCommand(), - array('paths' => array('images/cats.jpeg')), - array('filters' => array('thumbnail_web_path')) + array( + 'paths' => array('images/cats.jpeg'), + '--filters' => array('thumbnail_web_path')) ); $this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); + $this->assertFileNotExists($this->cacheRoot.'/thumbnail_default/images/cats.jpeg'); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats.jpeg', $output); } @@ -57,26 +58,30 @@ public function testShouldResolveWithCacheExists() $output = $this->executeConsole( new ResolveCacheCommand(), - array('paths' => array('images/cats.jpeg')), - array('filters' => array('thumbnail_web_path')) + array( + 'paths' => array('images/cats.jpeg'), + '--filters' => array('thumbnail_web_path')) ); + $this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); + $this->assertFileNotExists($this->cacheRoot.'/thumbnail_default/images/cats.jpeg'); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats.jpeg', $output); } - public function testShouldResolveWithFewPaths() + public function testShouldResolveWithFewPathsAndSingleFilter() { $output = $this->executeConsole( new ResolveCacheCommand(), - array('paths' => array('images/cats.jpeg', 'images/cats2.jpeg')), - array('filters' => array('thumbnail_web_path')) + array( + 'paths' => array('images/cats.jpeg', 'images/cats2.jpeg'), + '--filters' => array('thumbnail_web_path')) ); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats.jpeg', $output); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats2.jpeg', $output); } - public function testShouldResolveWithFewPathsAndPartiallyFullCache() + public function testShouldResolveWithFewPathsSingleFilterAndPartiallyFullCache() { $this->assertFileNotExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); @@ -87,10 +92,14 @@ public function testShouldResolveWithFewPathsAndPartiallyFullCache() $output = $this->executeConsole( new ResolveCacheCommand(), - array('paths' => array('images/cats.jpeg', 'images/cats2.jpeg')), - array('filters' => array('thumbnail_web_path')) + array( + 'paths' => array('images/cats.jpeg', 'images/cats2.jpeg'), + '--filters' => array('thumbnail_web_path')) ); + $this->assertFileNotExists($this->cacheRoot.'/thumbnail_default/images/cats.jpeg'); + $this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); + $this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats2.jpeg'); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats.jpeg', $output); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats2.jpeg', $output); } @@ -99,8 +108,9 @@ public function testShouldResolveWithFewPathsAndFewFilters() { $output = $this->executeConsole( new ResolveCacheCommand(), - array('paths' => array('images/cats.jpeg', 'images/cats2.jpeg')), - array('filters' => array('thumbnail_web_path', 'thumbnail_default')) + array( + 'paths' => array('images/cats.jpeg', 'images/cats2.jpeg'), + '--filters' => array('thumbnail_web_path', 'thumbnail_default')) ); $this->assertContains('http://localhost/media/cache/thumbnail_web_path/images/cats.jpeg', $output);