Skip to content

Commit

Permalink
Add failing test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwilson committed Sep 6, 2016
1 parent 0cd8678 commit 198273d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

sudo: false
Expand Down
16 changes: 8 additions & 8 deletions Tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,51 +54,51 @@ protected function createFilterConfiguration()

protected function getMockCacheManager()
{
return $this->getMock('Liip\ImagineBundle\Imagine\Cache\CacheManager', array(), array(), '', false);
return $this->getMockBuilder('Liip\ImagineBundle\Imagine\Cache\CacheManager')->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|FilterConfiguration
*/
protected function createFilterConfigurationMock()
{
return $this->getMock('Liip\ImagineBundle\Imagine\Filter\FilterConfiguration');
return $this->getMockBuilder('Liip\ImagineBundle\Imagine\Filter\FilterConfiguration')->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|RouterInterface
*/
protected function createRouterMock()
{
return $this->getMock('Symfony\Component\Routing\RouterInterface');
return $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|ResolverInterface
*/
protected function createResolverMock()
{
return $this->getMock('Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface');
return $this->getMockBuilder('Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface')->getMock();
}

protected function createEventDispatcherMock()
{
return $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
return $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
}

protected function getMockImage()
{
return $this->getMock('Imagine\Image\ImageInterface');
return $this->getMockBuilder('Imagine\Image\ImageInterface')->getMock();
}

protected function getMockMetaData()
{
return $this->getMock('Imagine\Image\Metadata\MetadataBag');
return $this->getMockBuilder('Imagine\Image\Metadata\MetadataBag')->getMock();
}

protected function createImagineMock()
{
return $this->getMock('Imagine\Image\ImagineInterface');
return $this->getMockBuilder('Imagine\Image\ImagineInterface')->getMock();
}

protected function tearDown()
Expand Down
46 changes: 46 additions & 0 deletions Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Liip\ImagineBundle\Tests\Filter;

use Liip\ImagineBundle\Imagine\Filter\Loader\ThumbnailFilterLoader;
use Liip\ImagineBundle\Tests\AbstractTest;
use Imagine\Image\Box;

/**
* Test cases for ThumbnailFilterLoader class.
*
* @covers Liip\ImagineBundle\Imagine\Filter\Loader\ThumbnailFilterLoader
*/
class ThumbnailFilterLoaderTest extends AbstractTest
{
/**
* @dataProvider heightWidthProvider
*/
public function testLoad($height, $width)
{
$loader = new ThumbnailFilterLoader();
$image = $this->getMockImage();
$image->method('getSize')->willReturn(new Box(20, 50));

$options = ['size' => [$height, $width]];

$result = $loader->load($image, $options);
}

/**
* @returns int[]
*/
public function heightWidthProvider()
{
return [
[100, 100],
[50, 50],
[1, 30],
[0, 30],
[30, 0],
[null, 16],
[37, null],
[null, null]
];
}
}

0 comments on commit 198273d

Please sign in to comment.