Skip to content

Commit

Permalink
Merge pull request #1243 from franmomu/clean_up_tests
Browse files Browse the repository at this point in the history
Use PHPUnit 7.5 and test clean up
  • Loading branch information
michellesanver authored Nov 27, 2019
2 parents 65e6992 + 0ebd1f5 commit bbac1a6
Show file tree
Hide file tree
Showing 101 changed files with 749 additions and 1,027 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
- SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
- PHPUNIT_FLAGS="-v"
- PHPUNIT_ENABLED="true"
- SYMFONY_PHPUNIT_VERSION="6.5"
- SYMFONY_PHPUNIT_VERSION="7.5"
- COVERALLS_ENABLED="false"
- STABILITY=stable

Expand Down
55 changes: 23 additions & 32 deletions Tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
use Liip\ImagineBundle\Imagine\Filter\PostProcessor\PostProcessorInterface;
use Liip\ImagineBundle\Service\FilterService;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand Down Expand Up @@ -77,7 +78,7 @@ protected function tearDown()
/**
* @return string[]
*/
public function invalidPathProvider()
public function invalidPathProvider(): array
{
return [
[$this->fixturesPath.'/assets/../../foobar.png'],
Expand All @@ -86,10 +87,7 @@ public function invalidPathProvider()
];
}

/**
* @return FilterConfiguration
*/
protected function createFilterConfiguration()
protected function createFilterConfiguration(): FilterConfiguration
{
$config = new FilterConfiguration();
$config->set('thumbnail', [
Expand All @@ -101,7 +99,7 @@ protected function createFilterConfiguration()
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|CacheManager
* @return MockObject|CacheManager
*/
protected function createCacheManagerMock()
{
Expand All @@ -117,95 +115,95 @@ protected function createCacheManagerMock()
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|FilterConfiguration
* @return MockObject|FilterConfiguration
*/
protected function createFilterConfigurationMock()
{
return $this->createObjectMock(FilterConfiguration::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|SignerInterface
* @return MockObject|SignerInterface
*/
protected function createSignerInterfaceMock()
{
return $this->createObjectMock(SignerInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|RouterInterface
* @return MockObject|RouterInterface
*/
protected function createRouterInterfaceMock()
{
return $this->createObjectMock(RouterInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|ResolverInterface
* @return MockObject|ResolverInterface
*/
protected function createCacheResolverInterfaceMock()
{
return $this->createObjectMock(ResolverInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|EventDispatcherInterface
* @return MockObject|EventDispatcherInterface
*/
protected function createEventDispatcherInterfaceMock()
{
return $this->createObjectMock(EventDispatcherInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|ImageInterface
* @return MockObject|ImageInterface
*/
protected function getImageInterfaceMock()
{
return $this->createObjectMock(ImageInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|MetadataBag
* @return MockObject|MetadataBag
*/
protected function getMetadataBagMock()
{
return $this->createObjectMock(MetadataBag::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|ImagineInterface
* @return MockObject|ImagineInterface
*/
protected function createImagineInterfaceMock()
{
return $this->createObjectMock(ImagineInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|LoggerInterface
* @return MockObject|LoggerInterface
*/
protected function createLoggerInterfaceMock()
{
return $this->createObjectMock(LoggerInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|LoaderInterface
* @return MockObject|LoaderInterface
*/
protected function createBinaryLoaderInterfaceMock()
{
return $this->createObjectMock(LoaderInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|MimeTypeGuesserInterface
* @return MockObject|MimeTypeGuesserInterface
*/
protected function createMimeTypeGuesserInterfaceMock()
{
return $this->createObjectMock(MimeTypeGuesserInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|ExtensionGuesserInterface
* @return MockObject|ExtensionGuesserInterface
*/
protected function createExtensionGuesserInterfaceMock()
{
Expand All @@ -217,31 +215,31 @@ protected function createExtensionGuesserInterfaceMock()
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|PostProcessorInterface
* @return MockObject|PostProcessorInterface
*/
protected function createPostProcessorInterfaceMock()
{
return $this->createObjectMock(PostProcessorInterface::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|FilterManager
* @return MockObject|FilterManager
*/
protected function createFilterManagerMock()
{
return $this->createObjectMock(FilterManager::class, [], false);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|FilterService
* @return MockObject|FilterService
*/
protected function createFilterServiceMock()
{
return $this->createObjectMock('\Liip\ImagineBundle\Service\FilterService');
return $this->createObjectMock(FilterService::class);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|DataManager
* @return MockObject|DataManager
*/
protected function createDataManagerMock()
{
Expand All @@ -254,14 +252,10 @@ protected function createControllerConfigInstance(int $redirectResponseCode = nu
}

/**
* @param string $object
* @param string[] $methods
* @param bool $constructorInvoke
* @param mixed[] $constructorParams
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function createObjectMock($object, array $methods = [], $constructorInvoke = false, array $constructorParams = [])
protected function createObjectMock(string $object, array $methods = [], bool $constructorInvoke = false, array $constructorParams = []): MockObject
{
$builder = $this->getMockBuilder($object);

Expand All @@ -284,11 +278,8 @@ protected function createObjectMock($object, array $methods = [], $constructorIn

/**
* @param object $object
* @param string $name
*
* @return \ReflectionMethod
*/
protected function getVisibilityRestrictedMethod($object, $name)
protected function getVisibilityRestrictedMethod($object, string $name): \ReflectionMethod
{
$r = new \ReflectionObject($object);

Expand Down
5 changes: 2 additions & 3 deletions Tests/Async/CacheResolvedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function setUpBeforeClass()
}
}

public function testCouldBeJsonSerialized()
public function testCouldBeJsonSerialized(): void
{
$message = new CacheResolved('thePath', [
'fooFilter' => 'http://example.com/fooFilter/thePath',
Expand All @@ -40,11 +40,10 @@ public function testCouldBeJsonSerialized()
);
}

public function testCouldBeJsonDeSerialized()
public function testCouldBeJsonDeSerialized(): void
{
$message = CacheResolved::jsonDeserialize('{"path":"thePath","uris":{"fooFilter":"http:\/\/example.com\/fooFilter\/thePath","barFilter":"http:\/\/example.com\/barFilter\/thePath"}}');

$this->assertInstanceOf('Liip\ImagineBundle\Async\CacheResolved', $message);
$this->assertSame('thePath', $message->getPath());
$this->assertSame([
'fooFilter' => 'http://example.com/fooFilter/thePath',
Expand Down
Loading

0 comments on commit bbac1a6

Please sign in to comment.