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

[1.0][cache] cache manager has to use isStored inside getBrowserPath method #303

Merged
merged 1 commit into from
Jan 20, 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
7 changes: 2 additions & 5 deletions Imagine/Cache/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ protected function getResolver($filter)
*/
public function getBrowserPath($path, $filter, $absolute = false)
{
//call it to make sure the resolver for the give filter exists.
$this->getResolver($filter);

return
$this->resolve($path, $filter) ?:
return $this->isStored($path, $filter) ?
$this->resolve($path, $filter) :
$this->generateUrl($path, $filter, $absolute)
;
}
Expand Down
14 changes: 12 additions & 2 deletions Tests/Imagine/Cache/CacheManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public function testGetBrowserPathWithoutResolver()
public function testDefaultResolverUsedIfNoneSetOnGetBrowserPath()
{
$resolver = $this->getMockResolver();
$resolver
->expects($this->once())
->method('isStored')
->with('cats.jpeg', 'thumbnail')
->will($this->returnValue(true))
;
$resolver
->expects($this->once())
->method('resolve')
Expand Down Expand Up @@ -95,9 +101,13 @@ public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBr
$resolver = $this->getMockResolver();
$resolver
->expects($this->once())
->method('resolve')
->method('isStored')
->with('cats.jpeg', 'thumbnail')
->will($this->returnValue(null))
->will($this->returnValue(false))
;
$resolver
->expects($this->never())
->method('resolve')
;

$config = $this->getMockFilterConfiguration();
Expand Down