public function testGetImageFromCache()
 {
     $cacheManager = $this->getMock('HtImgModule\\Service\\CacheManagerInterface');
     $cacheManager->expects($this->once())->method('cacheExists')->with('path/to/some/random/image/', 'foo_view_filter', 'jpeg')->will($this->returnValue(true));
     $cacheManager->expects($this->once())->method('getCacheUrl')->with('path/to/some/random/image/', 'foo_view_filter', 'jpeg')->will($this->returnValue('flowers.jpg'));
     $loaderManager = $this->getMock('HtImgModule\\Imagine\\Loader\\LoaderManagerInterface');
     $filterManager = $this->getMock('HtImgModule\\Imagine\\Filter\\FilterManagerInterface');
     $filterOptions = ['format' => 'jpeg'];
     $filterManager->expects($this->once())->method('getFilterOptions')->with('foo_view_filter')->will($this->returnValue($filterOptions));
     $cacheManager->expects($this->once())->method('isCachingEnabled')->with('foo_view_filter', $filterOptions)->will($this->returnValue(true));
     $helper = new ImgUrl($cacheManager, $filterManager, $loaderManager);
     $renderer = $this->getMock('Zend\\View\\Renderer\\PhpRenderer');
     $renderer->expects($this->once())->method('plugin')->with('basePath')->will($this->returnValue(function () {
         return '/app';
     }));
     $helper->setView($renderer);
     $this->assertEquals('/app/flowers.jpg', $helper('path/to/some/random/image/', 'foo_view_filter'));
 }
示例#2
0
 public function testGetImageFromCacheWithFullUrl()
 {
     $options = new ModuleOptions();
     $options->setCacheUrl('http://static.example.com');
     $cacheManager = $this->getMock('HtImgModule\\Service\\CacheManagerInterface', array('cacheExists', 'getCacheUrl', 'getCachePath', 'createCache', 'deleteCache', 'isCachingEnabled', 'useCacheUrl'), array($options));
     $cacheManager->expects($this->once())->method('cacheExists')->with('path/to/some/random/image/', 'foo_view_filter', 'jpeg')->will($this->returnValue(true));
     $cacheManager->expects($this->once())->method('useCacheUrl')->will($this->returnValue(true));
     $cacheManager->expects($this->once())->method('getCacheUrl')->with('path/to/some/random/image/', 'foo_view_filter', 'jpeg', true)->will($this->returnValue('http://static.example.com/foo_view_filter/path/to/some/random/image/flowers.jpg'));
     $loaderManager = $this->getMock('HtImgModule\\Imagine\\Loader\\LoaderManagerInterface');
     $filterManager = $this->getMock('HtImgModule\\Imagine\\Filter\\FilterManagerInterface');
     $filterOptions = ['format' => 'jpeg'];
     $filterManager->expects($this->once())->method('getFilterOptions')->with('foo_view_filter')->will($this->returnValue($filterOptions));
     $cacheManager->expects($this->once())->method('isCachingEnabled')->with('foo_view_filter', $filterOptions)->will($this->returnValue(true));
     $helper = new ImgUrl($cacheManager, $filterManager, $loaderManager);
     $renderer = $this->getMock('Zend\\View\\Renderer\\PhpRenderer');
     $helper->setView($renderer);
     $this->assertEquals('http://static.example.com/foo_view_filter/path/to/some/random/image/flowers.jpg', $helper('path/to/some/random/image/', 'foo_view_filter'));
 }