-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test case for ThumbnailFilterLoader.
- Loading branch information
1 parent
0cd8678
commit 1c5c7b2
Showing
3 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ php: | |
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
sudo: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Liip\ImagineBundle\Tests\Filter; | ||
|
||
use Liip\ImagineBundle\Imagine\Filter\Loader\ThumbnailFilterLoader; | ||
use Liip\ImagineBundle\Tests\AbstractTest; | ||
use Imagine\Image\Palette\Grayscale; | ||
use Imagine\Image\Box; | ||
|
||
/** | ||
* Test cases for ThumbnailFilterLoader class. | ||
* | ||
* @covers Liip\ImagineBundle\Imagine\Filter\Loader\ThumbnailFilterLoader | ||
*/ | ||
class ThumbnailFilterLoaderTest extends AbstractTest | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
const DUMMY_IMAGE_WIDTH = 500; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
const DUMMY_IMAGE_HEIGHT = 600; | ||
|
||
/** | ||
* @param int $width | ||
* @param int $height | ||
* @param Box $expected | ||
* | ||
* @dataProvider heightWidthProvider | ||
*/ | ||
public function testLoad($width, $height, $expected) | ||
{ | ||
$loader = new ThumbnailFilterLoader(); | ||
|
||
$mockImageSize = new Box( | ||
self::DUMMY_IMAGE_WIDTH, | ||
self::DUMMY_IMAGE_HEIGHT | ||
); | ||
$image = $this->getMockImage(); | ||
$image->method('getSize')->willReturn($mockImageSize); | ||
$image->method('copy')->willReturn($image); | ||
$image->expects($this->once()) | ||
->method('thumbnail') | ||
->with($expected) | ||
->willReturn($image); | ||
|
||
$options = []; | ||
$options['size'] = [$width, $height]; | ||
$options['allow_upscale'] = true; | ||
|
||
$result = $loader->load($image, $options); | ||
} | ||
|
||
/** | ||
* @returns array Array containing width/height pairs and an expected size. | ||
*/ | ||
public function heightWidthProvider() | ||
{ | ||
return [ | ||
[200, 129, new Box(200, 129)], | ||
[50, 50, new Box(50, 50)], | ||
[1, 30, new Box(1, 30)], | ||
[null, 60, new Box(50, 60)], | ||
[50, null, new Box(50, 60)], | ||
[1000, 1000, new Box(1000, 1000)] | ||
]; | ||
} | ||
} |