Skip to content

Commit

Permalink
Merge pull request #303 from formapro-forks/cache-manager-fix-browser…
Browse files Browse the repository at this point in the history
…-path

[1.0][cache] cache manager has to use isStored inside getBrowserPath method
  • Loading branch information
havvg committed Jan 20, 2014
2 parents 6fc4d98 + 6bdf92d commit abc48a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
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

0 comments on commit abc48a0

Please sign in to comment.