Skip to content

Commit

Permalink
Support for loader options
Browse files Browse the repository at this point in the history
  • Loading branch information
ojhaujjwal committed Aug 22, 2014
1 parent 84b3ca5 commit b049c2a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Imagine/Loader/LoaderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public function loadBinary($relativePath, $filter)
$imageLoader = $this->defaultImageLoader;
}
if (!is_object($imageLoader)) {
$imageLoader = $this->imageLoaders->get($imageLoader);
$imageLoader = $this->imageLoaders->get(
$imageLoader,
isset($filterOptions['loader_options']) ? $filterOptions['loader_options'] : []
);
}

$binary = $imageLoader->load($relativePath);
Expand Down
17 changes: 14 additions & 3 deletions tests/HtImgModuleTest/Imagine/Loader/LoaderManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ public function testGetExceptionWhenImageLoaderCannotLoadImage()
$loadManager->loadBinary($relativePath, 'asdf');
}

public function testLoadBinary()
public function getData()
{
return [
['awesome_image_loader', ['loader_options' => ['a' => []]]],
['awesome_image_loader_2', []],
];
}

/**
* @dataProvider getData
*/
public function testLoadBinary($imageLoaderName, $filterOptions)
{
$imageLoaders = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
$filterManager = $this->getMock('HtImgModule\Imagine\Filter\FilterManagerInterface');
Expand All @@ -37,14 +48,14 @@ public function testLoadBinary()

$relativePath = 'relative/path/of/some/image';
$filter = 'bar_filter';
$imageLoaderName = 'some_image_loader';
$binaryContent = 'asdf55asd4f53as4df54asdf564asdf';
$mimeType = 'image/png';
$filterOptions['image_loader'] = $imageLoaderName;

$filterManager->expects($this->once())
->method('getFilterOptions')
->with($filter)
->will($this->returnValue(['image_loader' => $imageLoaderName]));
->will($this->returnValue($filterOptions));

$imageLoaders->expects($this->once())
->method('get')
Expand Down

0 comments on commit b049c2a

Please sign in to comment.