From c044ac5af790f0876dd981bc789c1b4ff5d777eb Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:51:08 +0200 Subject: [PATCH 01/27] Bumping dependencies to support ZF3 --- composer.json | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index ae0fc37..70ce796 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,15 @@ ], "require": { "php": "~5.5|~7.0", - "zendframework/zend-servicemanager": "~2.3", - "zendframework/zend-mvc": "~2.3", - "zendframework/zend-view": "~2.3", - "zendframework/zend-cache": "~2.3", - "zendframework/zend-config": "~2.3" + "zendframework/zend-servicemanager": "^3.1.0", + "zendframework/zend-mvc": "^3.0", + "zendframework/zend-view": "^2.7", + "zendframework/zend-cache": "^2.7.1", + "zendframework/zend-config": "^2.6" }, "require-dev": { - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0", - "zendframework/zendframework": "2.*" + "phpunit/phpunit": "^5.4.2", + "squizlabs/php_codesniffer": "~2.6.1" }, "autoload": { "psr-0": { From f60efddeb247f89495f70dfc39e28a94a344bc8e Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:52:14 +0200 Subject: [PATCH 02/27] Making the `CacheFactory` compatible with zendframework/zend-servicemanager:3.x --- .../Factory/CacheFactory.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/OcraCachedViewResolver/Factory/CacheFactory.php b/src/OcraCachedViewResolver/Factory/CacheFactory.php index 3de9481..0274263 100644 --- a/src/OcraCachedViewResolver/Factory/CacheFactory.php +++ b/src/OcraCachedViewResolver/Factory/CacheFactory.php @@ -18,9 +18,11 @@ namespace OcraCachedViewResolver\Factory; +use Interop\Container\ContainerInterface; +use Interop\Container\Exception\ContainerException; +use Interop\Container\Exception\NotFoundException; use OcraCachedViewResolver\Module; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Zend\Cache\Exception\InvalidArgumentException; use Zend\Cache\StorageFactory; /** @@ -30,14 +32,18 @@ * @author Marco Pivetta * @license MIT */ -final class CacheFactory implements FactoryInterface +final class CacheFactory { /** * {@inheritDoc} + * + * @throws InvalidArgumentException + * @throws ContainerException + * @throws NotFoundException */ - public function createService(ServiceLocatorInterface $serviceLocator) + public function createService(ContainerInterface $container) { - $config = $serviceLocator->get('Config'); + $config = $container->get('Config'); return StorageFactory::factory($config[Module::CONFIG][Module::CONFIG_CACHE_DEFINITION]); } From 6d28e96052f69e67dcd8a2bc5bedb60cea9bab42 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:52:28 +0200 Subject: [PATCH 03/27] Making the `CompiledMapResolverDelegatorFactory` compatible with zendframework/zend-servicemanager:3.x --- .../Factory/CompiledMapResolverDelegatorFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php b/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php index f322173..66aefb9 100644 --- a/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php +++ b/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php @@ -18,11 +18,11 @@ namespace OcraCachedViewResolver\Factory; +use Interop\Container\ContainerInterface; use OcraCachedViewResolver\Module; use OcraCachedViewResolver\View\Resolver\CachingMapResolver; use OcraCachedViewResolver\View\Resolver\LazyResolver; -use Zend\ServiceManager\DelegatorFactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Zend\ServiceManager\Factory\DelegatorFactoryInterface; use Zend\View\Resolver\AggregateResolver; /** @@ -39,7 +39,7 @@ final class CompiledMapResolverDelegatorFactory implements DelegatorFactoryInter * * @return AggregateResolver */ - public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback) + public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) { $config = $serviceLocator->get('Config')[Module::CONFIG]; /* @var $cache \Zend\Cache\Storage\StorageInterface */ From 4c5905e8c16d9d6ff605b2215a4ca00dc4604f42 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:52:47 +0200 Subject: [PATCH 04/27] Removing support for PHP 5.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 70ce796..a7f4798 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "~5.5|~7.0", + "php": "~7.0", "zendframework/zend-servicemanager": "^3.1.0", "zendframework/zend-mvc": "^3.0", "zendframework/zend-view": "^2.7", From 5c4a60e8ab55fe4accabc6f4aa34574e846dad66 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:53:31 +0200 Subject: [PATCH 05/27] Adding return type hint, making the factory callable --- src/OcraCachedViewResolver/Factory/CacheFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OcraCachedViewResolver/Factory/CacheFactory.php b/src/OcraCachedViewResolver/Factory/CacheFactory.php index 0274263..dcfc0bf 100644 --- a/src/OcraCachedViewResolver/Factory/CacheFactory.php +++ b/src/OcraCachedViewResolver/Factory/CacheFactory.php @@ -23,6 +23,7 @@ use Interop\Container\Exception\NotFoundException; use OcraCachedViewResolver\Module; use Zend\Cache\Exception\InvalidArgumentException; +use Zend\Cache\Storage\StorageInterface; use Zend\Cache\StorageFactory; /** @@ -41,7 +42,7 @@ final class CacheFactory * @throws ContainerException * @throws NotFoundException */ - public function createService(ContainerInterface $container) + public function __invoke(ContainerInterface $container) : StorageInterface { $config = $container->get('Config'); From 6400caa956fe9d383d59c9cc119cab9414ba1b17 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:57:14 +0200 Subject: [PATCH 06/27] Removing reliance on deprecated test methods (`getMock`, specifically) --- .../Compiler/TemplateMapCompilerTest.php | 16 ++++++++-------- .../Factory/CacheFactoryTest.php | 2 +- .../CompiledMapResolverDelegatorFactoryTest.php | 6 +++--- .../ModuleFunctionalTest.php | 4 ++-- .../View/Resolver/CachingMapResolverTest.php | 8 ++++---- .../View/Resolver/LazyResolverTest.php | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php index 2f96f98..5b38e52 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php @@ -60,7 +60,7 @@ public function setUp() public function testCompileFromUnknownResolverProducesEmptyMap() { /* @var $resolver ResolverInterface */ - $resolver = $this->getMock(ResolverInterface::class); + $resolver = $this->createMock(ResolverInterface::class); $this->assertSame([], $this->compiler->compileMap($resolver)); } @@ -73,7 +73,7 @@ public function testCompileFromUnknownResolverProducesEmptyMap() public function testCompileFromMapResolver() { /* @var $mapResolver TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ - $mapResolver = $this->getMock(TemplateMapResolver::class); + $mapResolver = $this->createMock(TemplateMapResolver::class); $mapResolver ->expects($this->any()) ->method('getMap') @@ -94,8 +94,8 @@ public function testCompileFromMapResolver() public function testCompileFromTemplatePathStack() { /* @var $templatePathStack TemplatePathStack|\PHPUnit_Framework_MockObject_MockObject */ - $templatePathStack = $this->getMock(TemplatePathStack::class); - $paths = $this->getMock(SplStack::class); + $templatePathStack = $this->createMock(TemplatePathStack::class); + $paths = $this->createMock(SplStack::class); $paths ->expects($this->any()) ->method('toArray') @@ -139,21 +139,21 @@ public function testCompileFromTemplatePathStack() public function testCompileFromAggregateResolver() { /* @var $aggregateResolver AggregateResolver|\PHPUnit_Framework_MockObject_MockObject */ - $aggregateResolver = $this->getMock(AggregateResolver::class); + $aggregateResolver = $this->createMock(AggregateResolver::class); /* @var $mapResolver1 TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ - $mapResolver1 = $this->getMock(TemplateMapResolver::class); + $mapResolver1 = $this->createMock(TemplateMapResolver::class); $mapResolver1 ->expects($this->any()) ->method('getMap') ->will($this->returnValue(['a' => 'a-value', 'b' => 'b-value'])); /* @var $mapResolver2 TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ - $mapResolver2 = $this->getMock(TemplateMapResolver::class); + $mapResolver2 = $this->createMock(TemplateMapResolver::class); $mapResolver2 ->expects($this->any()) ->method('getMap') ->will($this->returnValue(['c' => 'c-value', 'd' => 'd-value'])); /* @var $mapResolver3 TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ - $mapResolver3 = $this->getMock(TemplateMapResolver::class); + $mapResolver3 = $this->createMock(TemplateMapResolver::class); $mapResolver3 ->expects($this->any()) ->method('getMap') diff --git a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php index cb449fc..8791153 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php @@ -39,7 +39,7 @@ class CacheFactoryTest extends PHPUnit_Framework_TestCase public function testCreateService() { /* @var $locator ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locator = $this->getMock(ServiceLocatorInterface::class); + $locator = $this->createMock(ServiceLocatorInterface::class); $locator->expects($this->any())->method('get')->with('Config')->will($this->returnValue([ Module::CONFIG => [ diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index d30f086..a484e61 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -61,9 +61,9 @@ class CompiledMapResolverDelegatorFactoryTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->locator = $this->getMock(ServiceLocatorInterface::class); - $this->callback = $this->getMock(stdClass::class, ['__invoke']); - $this->cache = $this->getMock(StorageInterface::class); + $this->locator = $this->createMock(ServiceLocatorInterface::class); + $this->callback = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); + $this->cache = $this->createMock(StorageInterface::class); $this->locator->expects($this->any())->method('get')->will($this->returnValueMap([ [ diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index 3722fd9..6de81b8 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -80,8 +80,8 @@ public function setUp() $this->originalResolver = new AggregateResolver(); /* @var $mapResolver TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ - $mapResolver = $this->getMock(TemplateMapResolver::class); - $this->fallbackResolver = $this->getMock(ResolverInterface::class); + $mapResolver = $this->createMock(TemplateMapResolver::class); + $this->fallbackResolver = $this->createMock(ResolverInterface::class); $mapResolver->expects($this->any())->method('getMap')->will($this->returnValue(['a' => 'b'])); diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index f567eaf..7535ef1 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -73,10 +73,10 @@ class CachingMapResolverTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resolverInstantiator = $this->getMock(stdClass::class, ['__invoke']); - $this->realResolver = $this->getMock(TemplateMapResolver::class); - $this->renderer = $this->getMock(RendererInterface::class); - $this->cache = $this->getMock(StorageInterface::class); + $this->resolverInstantiator = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); + $this->realResolver = $this->createMock(TemplateMapResolver::class); + $this->renderer = $this->createMock(RendererInterface::class); + $this->cache = $this->createMock(StorageInterface::class); $this->cachingMapResolver = new CachingMapResolver( $this->cache, $this->cacheKey, diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index 746116a..a80581f 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -64,9 +64,9 @@ class LazyResolverTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resolverInstantiator = $this->getMock(stdClass::class, ['__invoke']); - $this->realResolver = $this->getMock(ResolverInterface::class); - $this->renderer = $this->getMock(RendererInterface::class); + $this->resolverInstantiator = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); + $this->realResolver = $this->createMock(ResolverInterface::class); + $this->renderer = $this->createMock(RendererInterface::class); $this->lazyResolver = new LazyResolver($this->resolverInstantiator); } From d9f941c779397bacc36b6b7cd73e0b42b95533e6 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:57:48 +0200 Subject: [PATCH 07/27] Removing reliance on deprecated test methods (`setExpectedException`, specifically) --- .../View/Resolver/CachingMapResolverTest.php | 2 +- .../View/Resolver/LazyResolverTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index 7535ef1..5bfaad4 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -184,7 +184,7 @@ public function testLazyResolverRefusesInvalidRealResolver() $cachingMapResolver = new CachingMapResolver($this->cache, $this->cacheKey, $this->resolverInstantiator); - $this->setExpectedException(InvalidResolverInstantiatorException::class); + $this->expectException(InvalidResolverInstantiatorException::class); $cachingMapResolver->resolve('foo'); } diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index a80581f..3c60d37 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -146,7 +146,7 @@ public function testResolveCausesRealResolverInstantiationOnlyOnce() */ public function testLazyResolverRefusesNonCallableInstantiator() { - $this->setExpectedException(InvalidResolverInstantiatorException::class); + $this->expectException(InvalidResolverInstantiatorException::class); new LazyResolver($this); } @@ -164,7 +164,7 @@ public function testLazyResolverRefusesInvalidRealResolver() $lazyResolver = new LazyResolver($this->resolverInstantiator); - $this->setExpectedException(InvalidResolverInstantiatorException::class); + $this->expectException(InvalidResolverInstantiatorException::class); $lazyResolver->resolve('foo'); } From 4d395dd23f55362183c8b69c495bbaca5e80a141 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 21:59:15 +0200 Subject: [PATCH 08/27] Rewriting `CacheFactory` test to match the newly written API --- .../Factory/CacheFactoryTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php index 8791153..b8da378 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php @@ -18,11 +18,11 @@ namespace OcraCachedViewResolverTest\View\Resolver; +use Interop\Container\ContainerInterface; use OcraCachedViewResolver\Factory\CacheFactory; use OcraCachedViewResolver\Module; use PHPUnit_Framework_TestCase; use Zend\Cache\Storage\Adapter\Memory; -use Zend\ServiceManager\ServiceLocatorInterface; /** * Tests for {@see \OcraCachedViewResolver\Factory\CacheFactory} @@ -38,8 +38,8 @@ class CacheFactoryTest extends PHPUnit_Framework_TestCase { public function testCreateService() { - /* @var $locator ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locator = $this->createMock(ServiceLocatorInterface::class); + /* @var $locator ContainerInterface|\PHPUnit_Framework_MockObject_MockObject */ + $locator = $this->createMock(ContainerInterface::class); $locator->expects($this->any())->method('get')->with('Config')->will($this->returnValue([ Module::CONFIG => [ @@ -49,6 +49,6 @@ public function testCreateService() ], ])); - $this->assertInstanceOf(Memory::class, (new CacheFactory())->createService($locator)); + $this->assertInstanceOf(Memory::class, (new CacheFactory())->__invoke($locator)); } } From 02de3ee3b764a05c08e1a33d9fda9bea0186128e Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:03:50 +0200 Subject: [PATCH 09/27] Delegator factories now have a different order for parameters --- .../Factory/CompiledMapResolverDelegatorFactory.php | 9 +++++++-- .../CompiledMapResolverDelegatorFactoryTest.php | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php b/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php index 66aefb9..448b64e 100644 --- a/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php +++ b/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php @@ -19,6 +19,8 @@ namespace OcraCachedViewResolver\Factory; use Interop\Container\ContainerInterface; +use Interop\Container\Exception\ContainerException; +use Interop\Container\Exception\NotFoundException; use OcraCachedViewResolver\Module; use OcraCachedViewResolver\View\Resolver\CachingMapResolver; use OcraCachedViewResolver\View\Resolver\LazyResolver; @@ -38,12 +40,15 @@ final class CompiledMapResolverDelegatorFactory implements DelegatorFactoryInter * {@inheritDoc} * * @return AggregateResolver + * + * @throws ContainerException + * @throws NotFoundException */ public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) { - $config = $serviceLocator->get('Config')[Module::CONFIG]; + $config = $container->get('Config')[Module::CONFIG]; /* @var $cache \Zend\Cache\Storage\StorageInterface */ - $cache = $serviceLocator->get($config[Module::CONFIG_CACHE_SERVICE]); + $cache = $container->get($config[Module::CONFIG_CACHE_SERVICE]); $resolver = new AggregateResolver(); diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index a484e61..509784e 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -18,6 +18,7 @@ namespace OcraCachedViewResolverTest\View\Resolver; +use Interop\Container\ContainerInterface; use OcraCachedViewResolver\Factory\CompiledMapResolverDelegatorFactory; use OcraCachedViewResolver\Module; use OcraCachedViewResolver\View\Resolver\CachingMapResolver; @@ -25,7 +26,6 @@ use PHPUnit_Framework_TestCase; use stdClass; use Zend\Cache\Storage\StorageInterface; -use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Resolver\AggregateResolver; use Zend\View\Resolver\TemplateMapResolver; @@ -42,7 +42,7 @@ class CompiledMapResolverDelegatorFactoryTest extends PHPUnit_Framework_TestCase { /** - * @var ServiceLocatorInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ContainerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $locator; @@ -61,7 +61,7 @@ class CompiledMapResolverDelegatorFactoryTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->locator = $this->createMock(ServiceLocatorInterface::class); + $this->locator = $this->createMock(ContainerInterface::class); $this->callback = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); $this->cache = $this->createMock(StorageInterface::class); @@ -94,7 +94,7 @@ public function testCreateServiceWithExistingCachedTemplateMap() $this->callback->expects($this->never())->method('__invoke'); $factory = new CompiledMapResolverDelegatorFactory(); - $resolver = $factory->createDelegatorWithName($this->locator, 'resolver', 'resolver', $this->callback); + $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); $this->assertInstanceOf(AggregateResolver::class, $resolver); @@ -115,7 +115,7 @@ public function testCreateServiceWithEmptyCachedTemplateMap() $this->callback->expects($this->once())->method('__invoke')->will($this->returnValue($realResolver)); $factory = new CompiledMapResolverDelegatorFactory(); - $resolver = $factory->createDelegatorWithName($this->locator, 'resolver', 'resolver', $this->callback); + $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); $this->assertInstanceOf(AggregateResolver::class, $resolver); From 1b6bb6c8400fce91138f13b00bf943278081037d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:14:36 +0200 Subject: [PATCH 10/27] Master should become `4.1.x-dev` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a7f4798..36cc945 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.1.x-dev" } } } From 71c10e9a969a6aa0a0c4d1c9f9a76566e793508e Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:15:48 +0200 Subject: [PATCH 11/27] Documenting dependency bump, pointing 5.x users towards older versions --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 51b67a6..efd6777 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ OcraCachedViewResolver is performance-oriented Zend Framework 2 Module that increases performance in your application by caching the process of resolving template names to template paths. -In ZF2, the process of resolving template paths causes a lot of stat calls. This module adds +In ZF3, the process of resolving template paths causes a lot of stat calls. This module adds a cache layer to avoid that. | Tests | Releases | Downloads | Dependencies | @@ -19,8 +19,8 @@ The recommended way to install `ocramius/ocra-cached-view-resolver` is through php composer.phar require ocramius/ocra-cached-view-resolver:3.0.* ``` -If you use legacy/outdated PHP versions, such as `5.3.x` and `5.4.x`, you can use any -[`1.x`](https://github.com/Ocramius/OcraCachedViewResolver/tree/1.1.0) version +If you use legacy/outdated PHP versions, such as `5.5.x` and `5.6.x`, you can use any +[`3.x`](https://github.com/Ocramius/OcraCachedViewResolver/tree/3.0.0) version of `ocramius/ocra-cached-view-resolver`. You can then enable the module in your `config/application.config.php` by adding From 4a1ffb8f680b1c6be901ee6a62f22423fce42988 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:21:42 +0200 Subject: [PATCH 12/27] Refactoring functional test to enable the routing plugin (MVC refuses to run otherwise) --- .../ModuleFunctionalTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index 6de81b8..5d5ae4d 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -21,8 +21,9 @@ use OcraCachedViewResolver\View\Resolver\CachingMapResolver; use OcraCachedViewResolver\View\Resolver\LazyResolver; use PHPUnit_Framework_TestCase; -use Zend\ServiceManager\ServiceManager; +use Zend\Cache\Storage\StorageInterface; use Zend\Mvc\Service\ServiceManagerConfig; +use Zend\ServiceManager\ServiceManager; use Zend\View\Resolver\AggregateResolver; use Zend\View\Resolver\ResolverInterface; use Zend\View\Resolver\TemplateMapResolver; @@ -59,13 +60,18 @@ class ModuleFunctionalTest extends PHPUnit_Framework_TestCase */ public function setUp() { - $this->serviceManager = new ServiceManager(new ServiceManagerConfig()); + $this->serviceManager = new ServiceManager(); + + (new ServiceManagerConfig())->configureServiceManager($this->serviceManager); $this->serviceManager->setAllowOverride(true); $this->serviceManager->setService( 'ApplicationConfig', [ - 'modules' => ['OcraCachedViewResolver'], + 'modules' => [ + 'Zend\Router', + 'OcraCachedViewResolver', + ], 'module_listener_options' => [ 'config_glob_paths' => [ __DIR__ . '/../testing.config.php', @@ -100,7 +106,7 @@ function () use ($originalResolver) { public function testDefinedServices() { $this->assertInstanceOf( - 'Zend\\Cache\\Storage\\StorageInterface', + StorageInterface::class, $this->serviceManager->get('OcraCachedViewResolver\\Cache\\ResolverCache') ); @@ -129,13 +135,13 @@ public function testCachesResolvedTemplates() $this->assertFalse($cache->hasItem('testing_cache_key')); /* @var $resolver AggregateResolver */ - $resolver = $this->serviceManager->create('ViewResolver'); + $resolver = $this->serviceManager->build('ViewResolver'); $this->assertFalse($cache->hasItem('testing_cache_key')); $this->assertSame('b', $resolver->resolve('a')); $this->assertTrue($cache->hasItem('testing_cache_key')); $this->assertSame(['a' => 'b'], $cache->getItem('testing_cache_key')); - $this->serviceManager->create('ViewResolver'); + $this->serviceManager->build('ViewResolver'); } public function testFallbackResolverCall() From 87183f8989a5ed2acb93db8dc132ee1947a8d9e7 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:22:25 +0200 Subject: [PATCH 13/27] Removing deprecated instance calls on assertions --- .../TemplateMapCompilerFunctionalTest.php | 16 +++++----- .../Compiler/TemplateMapCompilerTest.php | 30 +++++++++---------- .../Factory/CacheFactoryTest.php | 2 +- ...ompiledMapResolverDelegatorFactoryTest.php | 16 +++++----- .../ModuleFunctionalTest.php | 20 ++++++------- .../OcraCachedViewResolverTest/ModuleTest.php | 4 +-- .../View/Resolver/CachingMapResolverTest.php | 16 +++++----- ...validResolverInstantiatorExceptionTest.php | 18 +++++------ .../View/Resolver/LazyResolverTest.php | 8 ++--- 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php index ddb2074..887de97 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php @@ -61,10 +61,10 @@ public function testCompileFromTemplatePathStack() $template2 = realpath(__DIR__ . '/_files/subdir2/template2.phtml'); $template4 = realpath(__DIR__ . '/_files/subdir1/valid/template4.phtml'); - $this->assertInternalType('string', $template2); - $this->assertInternalType('string', $template4); + self::assertInternalType('string', $template2); + self::assertInternalType('string', $template4); - $this->assertSame( + self::assertSame( [ 'template2' => $template2, 'valid/template4' => $template4, @@ -82,8 +82,8 @@ public function testCompileFromTemplatePathStackWithDifferentPaths() $template2 = realpath(__DIR__ . '/_files/subdir1/template2.phtml'); $template4 = realpath(__DIR__ . '/_files/subdir1/valid/template4.phtml'); - $this->assertInternalType('string', $template2); - $this->assertInternalType('string', $template4); + self::assertInternalType('string', $template2); + self::assertInternalType('string', $template4); // inverse directory order $resolver = new TemplatePathStack(); @@ -92,8 +92,8 @@ public function testCompileFromTemplatePathStackWithDifferentPaths() $map = $this->compiler->compileMap($resolver); - $this->assertCount(2, $map); - $this->assertSame($template2, $map['template2']); - $this->assertSame($template4, $map['valid/template4']); + self::assertCount(2, $map); + self::assertSame($template2, $map['template2']); + self::assertSame($template4, $map['valid/template4']); } } diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php index 5b38e52..83170fb 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php @@ -62,7 +62,7 @@ public function testCompileFromUnknownResolverProducesEmptyMap() /* @var $resolver ResolverInterface */ $resolver = $this->createMock(ResolverInterface::class); - $this->assertSame([], $this->compiler->compileMap($resolver)); + self::assertSame([], $this->compiler->compileMap($resolver)); } /** @@ -81,9 +81,9 @@ public function testCompileFromMapResolver() $map = $this->compiler->compileMap($mapResolver); - $this->assertCount(2, $map); - $this->assertSame('b', $map['a']); - $this->assertSame('d', $map['c']); + self::assertCount(2, $map); + self::assertSame('b', $map['a']); + self::assertSame('d', $map['c']); } /** @@ -119,16 +119,16 @@ public function testCompileFromTemplatePathStack() })); $map = $this->compiler->compileMap($templatePathStack); - $this->assertCount(2, $map); + self::assertCount(2, $map); $template2 = realpath(__DIR__ . '/_files/subdir2/template2.phtml'); $template4 = realpath(__DIR__ . '/_files/subdir1/valid/template4.phtml'); - $this->assertInternalType('string', $template2); - $this->assertInternalType('string', $template4); + self::assertInternalType('string', $template2); + self::assertInternalType('string', $template4); - $this->assertSame($template2, $map['template2']); - $this->assertSame($template4, $map['valid/template4']); + self::assertSame($template2, $map['template2']); + self::assertSame($template4, $map['valid/template4']); } /** @@ -167,11 +167,11 @@ public function testCompileFromAggregateResolver() $map = $this->compiler->compileMap($aggregateResolver); - $this->assertCount(5, $map); - $this->assertSame('a-value', $map['a']); // should not be overridden - $this->assertSame('b-value', $map['b']); - $this->assertSame('c-value', $map['c']); - $this->assertSame('d-value', $map['d']); // should not be overridden - $this->assertSame('e-value', $map['e']); + self::assertCount(5, $map); + self::assertSame('a-value', $map['a']); // should not be overridden + self::assertSame('b-value', $map['b']); + self::assertSame('c-value', $map['c']); + self::assertSame('d-value', $map['d']); // should not be overridden + self::assertSame('e-value', $map['e']); } } diff --git a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php index b8da378..d9f4693 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php @@ -49,6 +49,6 @@ public function testCreateService() ], ])); - $this->assertInstanceOf(Memory::class, (new CacheFactory())->__invoke($locator)); + self::assertInstanceOf(Memory::class, (new CacheFactory())->__invoke($locator)); } } diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index 509784e..a906cb1 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -96,14 +96,14 @@ public function testCreateServiceWithExistingCachedTemplateMap() $factory = new CompiledMapResolverDelegatorFactory(); $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); - $this->assertInstanceOf(AggregateResolver::class, $resolver); + self::assertInstanceOf(AggregateResolver::class, $resolver); $resolvers = $resolver->getIterator()->toArray(); - $this->assertInstanceOf(LazyResolver::class, $resolvers[0]); - $this->assertInstanceOf(CachingMapResolver::class, $resolvers[1]); + self::assertInstanceOf(LazyResolver::class, $resolvers[0]); + self::assertInstanceOf(CachingMapResolver::class, $resolvers[1]); - $this->assertSame('bar', $resolver->resolve('foo')); + self::assertSame('bar', $resolver->resolve('foo')); } public function testCreateServiceWithEmptyCachedTemplateMap() @@ -117,13 +117,13 @@ public function testCreateServiceWithEmptyCachedTemplateMap() $factory = new CompiledMapResolverDelegatorFactory(); $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); - $this->assertInstanceOf(AggregateResolver::class, $resolver); + self::assertInstanceOf(AggregateResolver::class, $resolver); $resolvers = $resolver->getIterator()->toArray(); - $this->assertInstanceOf(LazyResolver::class, $resolvers[0]); - $this->assertInstanceOf(CachingMapResolver::class, $resolvers[1]); + self::assertInstanceOf(LazyResolver::class, $resolvers[0]); + self::assertInstanceOf(CachingMapResolver::class, $resolvers[1]); - $this->assertSame('baz', $resolver->resolve('bar')); + self::assertSame('baz', $resolver->resolve('bar')); } } diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index 5d5ae4d..89d759e 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -105,7 +105,7 @@ function () use ($originalResolver) { public function testDefinedServices() { - $this->assertInstanceOf( + self::assertInstanceOf( StorageInterface::class, $this->serviceManager->get('OcraCachedViewResolver\\Cache\\ResolverCache') ); @@ -113,11 +113,11 @@ public function testDefinedServices() /* @var $resolver \Zend\View\Resolver\AggregateResolver */ $resolver = $this->serviceManager->get('ViewResolver'); - $this->assertInstanceOf(AggregateResolver::class, $resolver); - $this->assertSame($resolver, $this->serviceManager->get('ViewResolver')); + self::assertInstanceOf(AggregateResolver::class, $resolver); + self::assertSame($resolver, $this->serviceManager->get('ViewResolver')); foreach ($resolver->getIterator() as $previousResolver) { - $this->assertThat( + self::assertThat( $previousResolver, $this->logicalOr( $this->isInstanceOf(CachingMapResolver::class), @@ -132,15 +132,15 @@ public function testCachesResolvedTemplates() /* @var $cache \Zend\Cache\Storage\StorageInterface */ $cache = $this->serviceManager->get('OcraCachedViewResolver\\Cache\\ResolverCache'); - $this->assertFalse($cache->hasItem('testing_cache_key')); + self::assertFalse($cache->hasItem('testing_cache_key')); /* @var $resolver AggregateResolver */ $resolver = $this->serviceManager->build('ViewResolver'); - $this->assertFalse($cache->hasItem('testing_cache_key')); - $this->assertSame('b', $resolver->resolve('a')); - $this->assertTrue($cache->hasItem('testing_cache_key')); - $this->assertSame(['a' => 'b'], $cache->getItem('testing_cache_key')); + self::assertFalse($cache->hasItem('testing_cache_key')); + self::assertSame('b', $resolver->resolve('a')); + self::assertTrue($cache->hasItem('testing_cache_key')); + self::assertSame(['a' => 'b'], $cache->getItem('testing_cache_key')); $this->serviceManager->build('ViewResolver'); } @@ -156,6 +156,6 @@ public function testFallbackResolverCall() ->with('fallback.phtml') ->will($this->returnValue('fallback-path.phtml')); - $this->assertSame('fallback-path.phtml', $resolver->resolve('fallback.phtml')); + self::assertSame('fallback-path.phtml', $resolver->resolve('fallback.phtml')); } } diff --git a/tests/OcraCachedViewResolverTest/ModuleTest.php b/tests/OcraCachedViewResolverTest/ModuleTest.php index 21b4b9b..7e6354b 100644 --- a/tests/OcraCachedViewResolverTest/ModuleTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleTest.php @@ -33,13 +33,13 @@ class ModuleTest extends PHPUnit_Framework_TestCase { public function testConfigIsAnArray() { - $this->assertInternalType('array', (new Module())->getConfig()); + self::assertInternalType('array', (new Module())->getConfig()); } public function testConfigIsSerializable() { $module = new Module(); - $this->assertSame($module->getConfig(), unserialize(serialize($module->getConfig()))); + self::assertSame($module->getConfig(), unserialize(serialize($module->getConfig()))); } } diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index 5bfaad4..c258c22 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -108,7 +108,7 @@ public function testResolverCacheIsPopulatedOnResolve() ->method('setItem') ->with($this->cacheKey, ['view-name' => 'path/to/script']); - $this->assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); + self::assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); } public function testResolvingMultipleTimesDoesNotHitResolverInstantiatorOrCache() @@ -129,9 +129,9 @@ public function testResolvingMultipleTimesDoesNotHitResolverInstantiatorOrCache( ->method('setItem') ->with($this->cacheKey, ['view-name' => 'path/to/script']); - $this->assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); - $this->assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); - $this->assertFalse($this->cachingMapResolver->resolve('unknown-view-name', $this->renderer)); + self::assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); + self::assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); + self::assertFalse($this->cachingMapResolver->resolve('unknown-view-name', $this->renderer)); } public function testResolvingWithNonEmptyCacheWillNotHitResolverInstantiatorOrWriteToCache() @@ -146,9 +146,9 @@ public function testResolvingWithNonEmptyCacheWillNotHitResolverInstantiatorOrWr ->with($this->cacheKey) ->will($this->returnValue(['view-name' => 'path/to/cached/script'])); - $this->assertSame('path/to/cached/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); - $this->assertSame('path/to/cached/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); - $this->assertFalse($this->cachingMapResolver->resolve('unknown-view-name', $this->renderer)); + self::assertSame('path/to/cached/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); + self::assertSame('path/to/cached/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); + self::assertFalse($this->cachingMapResolver->resolve('unknown-view-name', $this->renderer)); } /** @@ -168,7 +168,7 @@ public function testResolveWithoutRenderer() ->with('view-name', null) ->will($this->returnValue('path/to/script')); - $this->assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name')); + self::assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name')); } /** diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/Exception/InvalidResolverInstantiatorExceptionTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/Exception/InvalidResolverInstantiatorExceptionTest.php index 5b99e96..c360ca3 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/Exception/InvalidResolverInstantiatorExceptionTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/Exception/InvalidResolverInstantiatorExceptionTest.php @@ -34,7 +34,7 @@ class InvalidResolverInstantiatorExceptionTest extends PHPUnit_Framework_TestCas { public function testInstanceOfBaseExceptionInterface() { - $this->assertInstanceOf( + self::assertInstanceOf( InvalidResolverInstantiatorException::class, new InvalidResolverInstantiatorException() ); @@ -44,8 +44,8 @@ public function testFromInvalidNullInstantiator() { $exception = InvalidResolverInstantiatorException::fromInvalidInstantiator(null); - $this->assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); - $this->assertSame( + self::assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); + self::assertSame( 'Invalid instantiator given, expected `callable`, `NULL` given.', $exception->getMessage() ); @@ -55,8 +55,8 @@ public function testFromInvalidObjectInstantiator() { $exception = InvalidResolverInstantiatorException::fromInvalidInstantiator($this); - $this->assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); - $this->assertSame( + self::assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); + self::assertSame( 'Invalid instantiator given, expected `callable`, `' . __CLASS__ . '` given.', $exception->getMessage() ); @@ -66,8 +66,8 @@ public function testFromInvalidNullResolver() { $exception = InvalidResolverInstantiatorException::fromInvalidResolver(null); - $this->assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); - $this->assertSame( + self::assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); + self::assertSame( 'Invalid resolver found, expected `Zend\View\Resolver\ResolverInterface`, `NULL` given.', $exception->getMessage() ); @@ -77,8 +77,8 @@ public function testFromInvalidObjectResolver() { $exception = InvalidResolverInstantiatorException::fromInvalidResolver($this); - $this->assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); - $this->assertSame( + self::assertInstanceOf(InvalidResolverInstantiatorException::class, $exception); + self::assertSame( 'Invalid resolver found, expected `Zend\View\Resolver\ResolverInterface`, `' . __CLASS__ . '` given.', $exception->getMessage() ); diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index 3c60d37..2564794 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -87,7 +87,7 @@ public function testResolve() ->with('view-name', $this->renderer) ->will($this->returnValue('path/to/script')); - $this->assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); + self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); } /** @@ -107,7 +107,7 @@ public function testResolveWithoutRenderer() ->with('view-name', null) ->will($this->returnValue('path/to/script')); - $this->assertSame('path/to/script', $this->lazyResolver->resolve('view-name')); + self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name')); } /** @@ -137,8 +137,8 @@ public function testResolveCausesRealResolverInstantiationOnlyOnce() ->with('view-name', $this->renderer) ->will($this->returnValue('path/to/script')); - $this->assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); - $this->assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); + self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); + self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); } /** From d48775f73da61a858db5729ea0d7a9165d991bed Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:23:16 +0200 Subject: [PATCH 14/27] Removing instance calls on matcher instantiators --- .../Compiler/TemplateMapCompilerTest.php | 30 +++++++++---------- .../Factory/CacheFactoryTest.php | 2 +- ...ompiledMapResolverDelegatorFactoryTest.php | 8 ++--- .../ModuleFunctionalTest.php | 4 +-- .../View/Resolver/CachingMapResolverTest.php | 18 +++++------ .../View/Resolver/LazyResolverTest.php | 18 +++++------ 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php index 83170fb..891c192 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php @@ -75,9 +75,9 @@ public function testCompileFromMapResolver() /* @var $mapResolver TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ $mapResolver = $this->createMock(TemplateMapResolver::class); $mapResolver - ->expects($this->any()) + ->expects(self::any()) ->method('getMap') - ->will($this->returnValue(['a' => 'b', 'c' => 'd'])); + ->will(self::returnValue(['a' => 'b', 'c' => 'd'])); $map = $this->compiler->compileMap($mapResolver); @@ -97,16 +97,16 @@ public function testCompileFromTemplatePathStack() $templatePathStack = $this->createMock(TemplatePathStack::class); $paths = $this->createMock(SplStack::class); $paths - ->expects($this->any()) + ->expects(self::any()) ->method('toArray') - ->will($this->returnValue([__DIR__ . '/_files/subdir2', __DIR__ . '/_files/subdir1'])); + ->will(self::returnValue([__DIR__ . '/_files/subdir2', __DIR__ . '/_files/subdir1'])); $templatePathStack - ->expects($this->any()) + ->expects(self::any()) ->method('getPaths') - ->will($this->returnValue($paths)); + ->will(self::returnValue($paths)); $templatePathStack - ->expects($this->any()) + ->expects(self::any()) ->method('resolve') ->will($this->returnCallback(function ($name) { $keys = [ @@ -143,27 +143,27 @@ public function testCompileFromAggregateResolver() /* @var $mapResolver1 TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ $mapResolver1 = $this->createMock(TemplateMapResolver::class); $mapResolver1 - ->expects($this->any()) + ->expects(self::any()) ->method('getMap') - ->will($this->returnValue(['a' => 'a-value', 'b' => 'b-value'])); + ->will(self::returnValue(['a' => 'a-value', 'b' => 'b-value'])); /* @var $mapResolver2 TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ $mapResolver2 = $this->createMock(TemplateMapResolver::class); $mapResolver2 - ->expects($this->any()) + ->expects(self::any()) ->method('getMap') - ->will($this->returnValue(['c' => 'c-value', 'd' => 'd-value'])); + ->will(self::returnValue(['c' => 'c-value', 'd' => 'd-value'])); /* @var $mapResolver3 TemplateMapResolver|\PHPUnit_Framework_MockObject_MockObject */ $mapResolver3 = $this->createMock(TemplateMapResolver::class); $mapResolver3 - ->expects($this->any()) + ->expects(self::any()) ->method('getMap') - ->will($this->returnValue(['a' => 'override-a-value', 'd' => 'override-d-value', 'e' => 'e-value'])); + ->will(self::returnValue(['a' => 'override-a-value', 'd' => 'override-d-value', 'e' => 'e-value'])); $iterator = new ArrayIterator([$mapResolver1, $mapResolver2, $mapResolver3]); $aggregateResolver - ->expects($this->any()) + ->expects(self::any()) ->method('getIterator') - ->will($this->returnValue($iterator)); + ->will(self::returnValue($iterator)); $map = $this->compiler->compileMap($aggregateResolver); diff --git a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php index d9f4693..edeeb87 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CacheFactoryTest.php @@ -41,7 +41,7 @@ public function testCreateService() /* @var $locator ContainerInterface|\PHPUnit_Framework_MockObject_MockObject */ $locator = $this->createMock(ContainerInterface::class); - $locator->expects($this->any())->method('get')->with('Config')->will($this->returnValue([ + $locator->expects(self::any())->method('get')->with('Config')->will(self::returnValue([ Module::CONFIG => [ Module::CONFIG_CACHE_DEFINITION => [ 'adapter' => Memory::class, diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index a906cb1..78e2f6b 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -65,7 +65,7 @@ protected function setUp() $this->callback = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); $this->cache = $this->createMock(StorageInterface::class); - $this->locator->expects($this->any())->method('get')->will($this->returnValueMap([ + $this->locator->expects(self::any())->method('get')->will(self::returnValueMap([ [ 'Config', [ @@ -89,7 +89,7 @@ public function testCreateServiceWithExistingCachedTemplateMap() ->expects($this->once()) ->method('getItem') ->with('key-name') - ->will($this->returnValue(['foo' => 'bar'])); + ->will(self::returnValue(['foo' => 'bar'])); $this->callback->expects($this->never())->method('__invoke'); @@ -110,9 +110,9 @@ public function testCreateServiceWithEmptyCachedTemplateMap() { $realResolver = new TemplateMapResolver(['bar' => 'baz']); - $this->cache->expects($this->once())->method('getItem')->with('key-name')->will($this->returnValue(null)); + $this->cache->expects($this->once())->method('getItem')->with('key-name')->will(self::returnValue(null)); $this->cache->expects($this->once())->method('setItem')->with('key-name', ['bar' => 'baz']); - $this->callback->expects($this->once())->method('__invoke')->will($this->returnValue($realResolver)); + $this->callback->expects($this->once())->method('__invoke')->will(self::returnValue($realResolver)); $factory = new CompiledMapResolverDelegatorFactory(); $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index 89d759e..0d607b9 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -89,7 +89,7 @@ public function setUp() $mapResolver = $this->createMock(TemplateMapResolver::class); $this->fallbackResolver = $this->createMock(ResolverInterface::class); - $mapResolver->expects($this->any())->method('getMap')->will($this->returnValue(['a' => 'b'])); + $mapResolver->expects(self::any())->method('getMap')->will(self::returnValue(['a' => 'b'])); $this->originalResolver->attach($mapResolver, 10); $this->originalResolver->attach($this->fallbackResolver, 5); @@ -154,7 +154,7 @@ public function testFallbackResolverCall() ->expects($this->once()) ->method('resolve') ->with('fallback.phtml') - ->will($this->returnValue('fallback-path.phtml')); + ->will(self::returnValue('fallback-path.phtml')); self::assertSame('fallback-path.phtml', $resolver->resolve('fallback.phtml')); } diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index c258c22..668a267 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -85,9 +85,9 @@ protected function setUp() $this ->realResolver - ->expects($this->any()) + ->expects(self::any()) ->method('getMap') - ->will($this->returnValue(['view-name' => 'path/to/script'])); + ->will(self::returnValue(['view-name' => 'path/to/script'])); } public function testResolverCacheIsPopulatedOnResolve() @@ -96,7 +96,7 @@ public function testResolverCacheIsPopulatedOnResolve() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue($this->realResolver)); + ->will(self::returnValue($this->realResolver)); $this ->cache ->expects($this->once()) @@ -117,7 +117,7 @@ public function testResolvingMultipleTimesDoesNotHitResolverInstantiatorOrCache( ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue($this->realResolver)); + ->will(self::returnValue($this->realResolver)); $this ->cache ->expects($this->once()) @@ -144,7 +144,7 @@ public function testResolvingWithNonEmptyCacheWillNotHitResolverInstantiatorOrWr ->expects($this->once()) ->method('getItem') ->with($this->cacheKey) - ->will($this->returnValue(['view-name' => 'path/to/cached/script'])); + ->will(self::returnValue(['view-name' => 'path/to/cached/script'])); self::assertSame('path/to/cached/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); self::assertSame('path/to/cached/script', $this->cachingMapResolver->resolve('view-name', $this->renderer)); @@ -160,13 +160,13 @@ public function testResolveWithoutRenderer() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue($this->realResolver)); + ->will(self::returnValue($this->realResolver)); $this ->realResolver - ->expects($this->any()) + ->expects(self::any()) ->method('resolve') ->with('view-name', null) - ->will($this->returnValue('path/to/script')); + ->will(self::returnValue('path/to/script')); self::assertSame('path/to/script', $this->cachingMapResolver->resolve('view-name')); } @@ -180,7 +180,7 @@ public function testLazyResolverRefusesInvalidRealResolver() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue(null)); + ->will(self::returnValue(null)); $cachingMapResolver = new CachingMapResolver($this->cache, $this->cacheKey, $this->resolverInstantiator); diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index 2564794..e6fdae4 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -79,13 +79,13 @@ public function testResolve() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue($this->realResolver)); + ->will(self::returnValue($this->realResolver)); $this ->realResolver - ->expects($this->any()) + ->expects(self::any()) ->method('resolve') ->with('view-name', $this->renderer) - ->will($this->returnValue('path/to/script')); + ->will(self::returnValue('path/to/script')); self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); } @@ -99,13 +99,13 @@ public function testResolveWithoutRenderer() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue($this->realResolver)); + ->will(self::returnValue($this->realResolver)); $this ->realResolver - ->expects($this->any()) + ->expects(self::any()) ->method('resolve') ->with('view-name', null) - ->will($this->returnValue('path/to/script')); + ->will(self::returnValue('path/to/script')); self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name')); } @@ -129,13 +129,13 @@ public function testResolveCausesRealResolverInstantiationOnlyOnce() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue($this->realResolver)); + ->will(self::returnValue($this->realResolver)); $this ->realResolver ->expects($this->exactly(2)) ->method('resolve') ->with('view-name', $this->renderer) - ->will($this->returnValue('path/to/script')); + ->will(self::returnValue('path/to/script')); self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); self::assertSame('path/to/script', $this->lazyResolver->resolve('view-name', $this->renderer)); @@ -160,7 +160,7 @@ public function testLazyResolverRefusesInvalidRealResolver() ->resolverInstantiator ->expects($this->once()) ->method('__invoke') - ->will($this->returnValue(null)); + ->will(self::returnValue(null)); $lazyResolver = new LazyResolver($this->resolverInstantiator); From 04fb841fd3510901a6ddcf4b5232149f12ccda21 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:23:44 +0200 Subject: [PATCH 15/27] Removing instance calls on matcher instantiators --- ...CompiledMapResolverDelegatorFactoryTest.php | 8 ++++---- .../ModuleFunctionalTest.php | 2 +- .../View/Resolver/CachingMapResolverTest.php | 18 +++++++++--------- .../View/Resolver/LazyResolverTest.php | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index 78e2f6b..aac033c 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -86,7 +86,7 @@ public function testCreateServiceWithExistingCachedTemplateMap() { $this ->cache - ->expects($this->once()) + ->expects(self::once()) ->method('getItem') ->with('key-name') ->will(self::returnValue(['foo' => 'bar'])); @@ -110,9 +110,9 @@ public function testCreateServiceWithEmptyCachedTemplateMap() { $realResolver = new TemplateMapResolver(['bar' => 'baz']); - $this->cache->expects($this->once())->method('getItem')->with('key-name')->will(self::returnValue(null)); - $this->cache->expects($this->once())->method('setItem')->with('key-name', ['bar' => 'baz']); - $this->callback->expects($this->once())->method('__invoke')->will(self::returnValue($realResolver)); + $this->cache->expects(self::once())->method('getItem')->with('key-name')->will(self::returnValue(null)); + $this->cache->expects(self::once())->method('setItem')->with('key-name', ['bar' => 'baz']); + $this->callback->expects(self::once())->method('__invoke')->will(self::returnValue($realResolver)); $factory = new CompiledMapResolverDelegatorFactory(); $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index 0d607b9..04136b9 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -151,7 +151,7 @@ public function testFallbackResolverCall() $this ->fallbackResolver - ->expects($this->once()) + ->expects(self::once()) ->method('resolve') ->with('fallback.phtml') ->will(self::returnValue('fallback-path.phtml')); diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index 668a267..5006951 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -94,17 +94,17 @@ public function testResolverCacheIsPopulatedOnResolve() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue($this->realResolver)); $this ->cache - ->expects($this->once()) + ->expects(self::once()) ->method('getItem') ->with($this->cacheKey); $this ->cache - ->expects($this->once()) + ->expects(self::once()) ->method('setItem') ->with($this->cacheKey, ['view-name' => 'path/to/script']); @@ -115,17 +115,17 @@ public function testResolvingMultipleTimesDoesNotHitResolverInstantiatorOrCache( { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue($this->realResolver)); $this ->cache - ->expects($this->once()) + ->expects(self::once()) ->method('getItem') ->with($this->cacheKey); $this ->cache - ->expects($this->once()) + ->expects(self::once()) ->method('setItem') ->with($this->cacheKey, ['view-name' => 'path/to/script']); @@ -141,7 +141,7 @@ public function testResolvingWithNonEmptyCacheWillNotHitResolverInstantiatorOrWr $this ->cache - ->expects($this->once()) + ->expects(self::once()) ->method('getItem') ->with($this->cacheKey) ->will(self::returnValue(['view-name' => 'path/to/cached/script'])); @@ -158,7 +158,7 @@ public function testResolveWithoutRenderer() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue($this->realResolver)); $this @@ -178,7 +178,7 @@ public function testLazyResolverRefusesInvalidRealResolver() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue(null)); diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index e6fdae4..8ad47d1 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -77,7 +77,7 @@ public function testResolve() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue($this->realResolver)); $this @@ -97,7 +97,7 @@ public function testResolveWithoutRenderer() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue($this->realResolver)); $this @@ -127,7 +127,7 @@ public function testResolveCausesRealResolverInstantiationOnlyOnce() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue($this->realResolver)); $this @@ -158,7 +158,7 @@ public function testLazyResolverRefusesInvalidRealResolver() { $this ->resolverInstantiator - ->expects($this->once()) + ->expects(self::once()) ->method('__invoke') ->will(self::returnValue(null)); From 786b35a73e9960a184d00f0a0493cb64ab31ccf0 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:24:16 +0200 Subject: [PATCH 16/27] Removing instance calls on matcher instantiators --- .../Factory/CompiledMapResolverDelegatorFactoryTest.php | 2 +- .../View/Resolver/CachingMapResolverTest.php | 4 ++-- .../View/Resolver/LazyResolverTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index aac033c..94694cb 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -91,7 +91,7 @@ public function testCreateServiceWithExistingCachedTemplateMap() ->with('key-name') ->will(self::returnValue(['foo' => 'bar'])); - $this->callback->expects($this->never())->method('__invoke'); + $this->callback->expects(self::never())->method('__invoke'); $factory = new CompiledMapResolverDelegatorFactory(); $resolver = $factory->__invoke($this->locator, 'resolver', $this->callback); diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index 5006951..8f54d1e 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -136,8 +136,8 @@ public function testResolvingMultipleTimesDoesNotHitResolverInstantiatorOrCache( public function testResolvingWithNonEmptyCacheWillNotHitResolverInstantiatorOrWriteToCache() { - $this->resolverInstantiator->expects($this->never())->method('__invoke'); - $this->cache->expects($this->never())->method('setItem'); + $this->resolverInstantiator->expects(self::never())->method('__invoke'); + $this->cache->expects(self::never())->method('setItem'); $this ->cache diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index 8ad47d1..55c8561 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -115,7 +115,7 @@ public function testResolveWithoutRenderer() */ public function testRealResolverNotCreatedIfNotNeeded() { - $this->resolverInstantiator->expects($this->never())->method('__invoke'); + $this->resolverInstantiator->expects(self::never())->method('__invoke'); new LazyResolver($this->resolverInstantiator); } From 1e8ab2c8837c81320c95ecd3613b0e74efad1351 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:25:08 +0200 Subject: [PATCH 17/27] Removing instance calls on matcher instantiators --- .../Compiler/TemplateMapCompilerTest.php | 4 ++-- tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php | 6 +++--- .../View/Resolver/LazyResolverTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php index 891c192..f5eeff4 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php @@ -108,7 +108,7 @@ public function testCompileFromTemplatePathStack() $templatePathStack ->expects(self::any()) ->method('resolve') - ->will($this->returnCallback(function ($name) { + ->willReturnCallback(function ($name) { $keys = [ 'template2' => __DIR__ . '/_files/subdir2/template2.phtml', 'template3' => false, @@ -116,7 +116,7 @@ public function testCompileFromTemplatePathStack() ]; return $keys[$name]; - })); + }); $map = $this->compiler->compileMap($templatePathStack); self::assertCount(2, $map); diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index 04136b9..c726cbd 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -119,9 +119,9 @@ public function testDefinedServices() foreach ($resolver->getIterator() as $previousResolver) { self::assertThat( $previousResolver, - $this->logicalOr( - $this->isInstanceOf(CachingMapResolver::class), - $this->isInstanceOf(LazyResolver::class) + self::logicalOr( + self::isInstanceOf(CachingMapResolver::class), + self::isInstanceOf(LazyResolver::class) ) ); } diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index 55c8561..5327d10 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -132,7 +132,7 @@ public function testResolveCausesRealResolverInstantiationOnlyOnce() ->will(self::returnValue($this->realResolver)); $this ->realResolver - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('resolve') ->with('view-name', $this->renderer) ->will(self::returnValue('path/to/script')); From cb969e6a24d47da219552c52f4e48cdfdca1f177 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:28:29 +0200 Subject: [PATCH 18/27] Documenting thrown exceptions --- .../Compiler/TemplateMapCompilerFunctionalTest.php | 4 ++++ .../Compiler/TemplateMapCompilerTest.php | 8 ++++++++ .../Factory/CompiledMapResolverDelegatorFactoryTest.php | 2 ++ tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php | 6 ++++++ .../View/Resolver/CachingMapResolverTest.php | 2 ++ .../View/Resolver/LazyResolverTest.php | 2 +- 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php index 887de97..9bc3733 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerFunctionalTest.php @@ -51,6 +51,8 @@ public function setUp() /** * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileMap * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileFromTemplatePathStack + * + * @throws \Zend\View\Exception\InvalidArgumentException */ public function testCompileFromTemplatePathStack() { @@ -76,6 +78,8 @@ public function testCompileFromTemplatePathStack() /** * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileMap * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileFromTemplatePathStack + * + * @throws \Zend\View\Exception\InvalidArgumentException */ public function testCompileFromTemplatePathStackWithDifferentPaths() { diff --git a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php index f5eeff4..e01ff19 100644 --- a/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php +++ b/tests/OcraCachedViewResolverTest/Compiler/TemplateMapCompilerTest.php @@ -56,6 +56,8 @@ public function setUp() /** * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileMap + * + * @throws \PHPUnit_Framework_Exception */ public function testCompileFromUnknownResolverProducesEmptyMap() { @@ -69,6 +71,8 @@ public function testCompileFromUnknownResolverProducesEmptyMap() * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileMap * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileFromTemplateMapResolver * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::addResolvedPath + * + * @throws \PHPUnit_Framework_Exception */ public function testCompileFromMapResolver() { @@ -90,6 +94,8 @@ public function testCompileFromMapResolver() * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileMap * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileFromTemplatePathStack * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::addResolvedPath + * + * @throws \PHPUnit_Framework_Exception */ public function testCompileFromTemplatePathStack() { @@ -135,6 +141,8 @@ public function testCompileFromTemplatePathStack() * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileMap * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::compileFromAggregateResolver * @covers \OcraCachedViewResolver\Compiler\TemplateMapCompiler::addResolvedPath + * + * @throws \PHPUnit_Framework_Exception */ public function testCompileFromAggregateResolver() { diff --git a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php index 94694cb..6b0dadd 100644 --- a/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php +++ b/tests/OcraCachedViewResolverTest/Factory/CompiledMapResolverDelegatorFactoryTest.php @@ -58,6 +58,8 @@ class CompiledMapResolverDelegatorFactoryTest extends PHPUnit_Framework_TestCase /** * {@inheritDoc} + * + * @throws \PHPUnit_Framework_Exception */ protected function setUp() { diff --git a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php index c726cbd..9b92755 100644 --- a/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php +++ b/tests/OcraCachedViewResolverTest/ModuleFunctionalTest.php @@ -18,6 +18,8 @@ namespace OcraCachedViewResolverTest; +use Interop\Container\Exception\ContainerException; +use Interop\Container\Exception\NotFoundException; use OcraCachedViewResolver\View\Resolver\CachingMapResolver; use OcraCachedViewResolver\View\Resolver\LazyResolver; use PHPUnit_Framework_TestCase; @@ -57,6 +59,10 @@ class ModuleFunctionalTest extends PHPUnit_Framework_TestCase /** * {@inheritDoc} + * + * @throws \PHPUnit_Framework_Exception + * @throws ContainerException + * @throws NotFoundException */ public function setUp() { diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index 8f54d1e..f71dd43 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -70,6 +70,8 @@ class CachingMapResolverTest extends PHPUnit_Framework_TestCase /** * {@inheritDoc} + * + * @throws \PHPUnit_Framework_Exception */ protected function setUp() { diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php index 5327d10..e795923 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/LazyResolverTest.php @@ -60,7 +60,7 @@ class LazyResolverTest extends PHPUnit_Framework_TestCase /** * {@inheritDoc} * - * @covers \OcraCachedViewResolver\View\Resolver\LazyResolver::__construct + * @throws \PHPUnit_Framework_Exception */ protected function setUp() { From 593a57717ccd984ffcc2079a6ebc743616869b5e Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:30:14 +0200 Subject: [PATCH 19/27] Adding return types to the `TemplateMapCompiler` --- .../Compiler/TemplateMapCompiler.php | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php b/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php index e54d995..58e95aa 100644 --- a/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php +++ b/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php @@ -47,7 +47,7 @@ class TemplateMapCompiler * * @return array */ - public function compileMap(ResolverInterface $resolver) + public function compileMap(ResolverInterface $resolver) : array { if ($resolver instanceof AggregateResolver) { return $this->compileFromAggregateResolver($resolver); @@ -64,12 +64,7 @@ public function compileMap(ResolverInterface $resolver) return []; } - /** - * @param AggregateResolver $resolver - * - * @return array - */ - protected function compileFromAggregateResolver(AggregateResolver $resolver) + protected function compileFromAggregateResolver(AggregateResolver $resolver) : array { $map = []; @@ -85,8 +80,10 @@ protected function compileFromAggregateResolver(AggregateResolver $resolver) * @param TemplatePathStack $resolver * * @return array + * + * @throws \Zend\View\Exception\DomainException */ - protected function compileFromTemplatePathStack(TemplatePathStack $resolver) + protected function compileFromTemplatePathStack(TemplatePathStack $resolver) : array { $map = []; @@ -105,12 +102,7 @@ protected function compileFromTemplatePathStack(TemplatePathStack $resolver) return $map; } - /** - * @param TemplateMapResolver $resolver - * - * @return array - */ - protected function compileFromTemplateMapResolver(TemplateMapResolver $resolver) + protected function compileFromTemplateMapResolver(TemplateMapResolver $resolver) : array { return $resolver->getMap(); } @@ -124,6 +116,8 @@ protected function compileFromTemplateMapResolver(TemplateMapResolver $resolver) * @param TemplatePathStack $resolver * * @return void + * + * @throws \Zend\View\Exception\DomainException */ private function addResolvedPath(SplFileInfo $file, array & $map, $basePath, TemplatePathStack $resolver) { From 9138932225a996e45edc10773203d4e967ce68a4 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:30:48 +0200 Subject: [PATCH 20/27] Adding return types to the module --- src/OcraCachedViewResolver/Module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OcraCachedViewResolver/Module.php b/src/OcraCachedViewResolver/Module.php index 155ccd3..ce76324 100644 --- a/src/OcraCachedViewResolver/Module.php +++ b/src/OcraCachedViewResolver/Module.php @@ -56,7 +56,7 @@ final class Module implements ConfigProviderInterface /** * {@inheritDoc} */ - public function getConfig() + public function getConfig() : array { return [ self::CONFIG => [ From ccef44a9fa909985d4cb0b4c4e7cd6221d06ceb1 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:31:00 +0200 Subject: [PATCH 21/27] Documenting thrown exceptions --- src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php b/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php index 58e95aa..f43ecf0 100644 --- a/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php +++ b/src/OcraCachedViewResolver/Compiler/TemplateMapCompiler.php @@ -46,6 +46,8 @@ class TemplateMapCompiler * @param ResolverInterface $resolver * * @return array + * + * @throws \Zend\View\Exception\DomainException */ public function compileMap(ResolverInterface $resolver) : array { From 9d691860e904477e58a9b0d6f50e2cb80b1daa1d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:33:04 +0200 Subject: [PATCH 22/27] Adding return type to the `CompiledMapResolverDelegatorFactory` --- .../Factory/CompiledMapResolverDelegatorFactory.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php b/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php index 448b64e..be89fa2 100644 --- a/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php +++ b/src/OcraCachedViewResolver/Factory/CompiledMapResolverDelegatorFactory.php @@ -26,6 +26,7 @@ use OcraCachedViewResolver\View\Resolver\LazyResolver; use Zend\ServiceManager\Factory\DelegatorFactoryInterface; use Zend\View\Resolver\AggregateResolver; +use Zend\View\Resolver\ResolverInterface; /** * Factory responsible of building a {@see \Zend\View\Resolver\TemplateMapResolver} @@ -44,8 +45,12 @@ final class CompiledMapResolverDelegatorFactory implements DelegatorFactoryInter * @throws ContainerException * @throws NotFoundException */ - public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) - { + public function __invoke( + ContainerInterface $container, + $name, + callable $callback, + array $options = null + ) : ResolverInterface { $config = $container->get('Config')[Module::CONFIG]; /* @var $cache \Zend\Cache\Storage\StorageInterface */ $cache = $container->get($config[Module::CONFIG_CACHE_SERVICE]); From 53f0f3a9b01f699cb02ee8451491752600cdd333 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:33:36 +0200 Subject: [PATCH 23/27] CS (whitespace) --- .../View/Resolver/CachingMapResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php index f71dd43..9a15118 100644 --- a/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php +++ b/tests/OcraCachedViewResolverTest/View/Resolver/CachingMapResolverTest.php @@ -70,7 +70,7 @@ class CachingMapResolverTest extends PHPUnit_Framework_TestCase /** * {@inheritDoc} - * + * * @throws \PHPUnit_Framework_Exception */ protected function setUp() From 2136f2a7888b3aae1289d164b1af50c6f02e8899 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:35:24 +0200 Subject: [PATCH 24/27] Adding return types to the `InvalidResolverInstantiatorException` --- .../Exception/InvalidResolverInstantiatorException.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OcraCachedViewResolver/View/Resolver/Exception/InvalidResolverInstantiatorException.php b/src/OcraCachedViewResolver/View/Resolver/Exception/InvalidResolverInstantiatorException.php index 7179d53..0bc49fa 100644 --- a/src/OcraCachedViewResolver/View/Resolver/Exception/InvalidResolverInstantiatorException.php +++ b/src/OcraCachedViewResolver/View/Resolver/Exception/InvalidResolverInstantiatorException.php @@ -34,7 +34,7 @@ final class InvalidResolverInstantiatorException extends InvalidArgumentExceptio * * @return self */ - public static function fromInvalidInstantiator($instantiator) + public static function fromInvalidInstantiator($instantiator) : self { return new self(sprintf( 'Invalid instantiator given, expected `callable`, `%s` given.', @@ -47,7 +47,7 @@ public static function fromInvalidInstantiator($instantiator) * * @return self */ - public static function fromInvalidResolver($resolver) + public static function fromInvalidResolver($resolver) : self { return new self(sprintf( 'Invalid resolver found, expected `' . ResolverInterface::class . '`, `%s` given.', From c1b0c0d3acc673a01cbf6cf176280c39a28c488f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:37:01 +0200 Subject: [PATCH 25/27] PHP 5.x does not need to be tested anymore --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9807d3..31adbfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ language: php sudo: false php: - - 5.5 - - 5.6 - 7.0 - hhvm From 915700ed94064a880055d36f8a1d60f867019279 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:38:57 +0200 Subject: [PATCH 26/27] HHVM is allowed to fail --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 31adbfd..c386823 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,10 @@ env: - DEPENDENCIES="" - DEPENDENCIES="--prefer-lowest --prefer-stable" +matrix: + allow_failures: + - php: hhvm + before_script: - composer self-update - composer update --prefer-source $DEPENDENCIES From a1f455b46ff4e3f564bedc6617260ed6ed35a7a5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 4 Jun 2016 22:44:49 +0200 Subject: [PATCH 27/27] Documenting 4.0.0 changes --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..69d8193 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog + +All notable changes to this project will be documented in this file, in reverse chronological order by release. + +## 4.0.0 - 2016-06-04 + +### Added + +- Support for `zendframework/zend-mvc` 3.x + +### Deprecated + +- Nothing. + +### Removed + +- Support for PHP 5 has been dropped +- Factories now follow the interfaces suggested by `zendframework/zend-servicemanager` 3.x + +### Fixed + +- Nothing.