Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed and improved tests for resolve cache command #386

Merged
merged 2 commits into from
Apr 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Command/ResolveCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ protected function configure()
'f',
InputOption::VALUE_OPTIONAL|InputOption::VALUE_IS_ARRAY,
'Filters list'
)->setHelp(<<<EOF
The <info>%command.name%</info> command resolves cache by specified parameters.
It returns list of urls.

<info>php app/console %command.name% path1 path2 --filters=thumb1</info>
Cache for this two paths will be resolved with passed filter.
As a result you will get<info>
http://localhost/media/cache/thumb1/path1
http://localhost/media/cache/thumb1/path2</info>

You can pass few filters:
<info>php app/console %command.name% path1 --filters=thumb1 --filters=thumb2</info>
As a result you will get<info>
http://localhost/media/cache/thumb1/path1
http://localhost/media/cache/thumb2/path1</info>

If you omit --filters parameter then to resolve given paths will be used all configured and available filters in application:
<info>php app/console %command.name% path1</info>
As a result you will get<info>
http://localhost/media/cache/thumb1/path1
http://localhost/media/cache/thumb2/path1</info>
EOF
);
}

Expand Down
36 changes: 23 additions & 13 deletions Tests/Functional/Command/ResolveCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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');

Expand All @@ -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);
}
Expand All @@ -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);
Expand Down