From 0b110fb0cf9457ab9ae09785eabf3f03c93d98bd Mon Sep 17 00:00:00 2001 From: Vallabh Kansagara Date: Sat, 29 Aug 2020 04:39:47 +0530 Subject: [PATCH 01/21] removal of deprecated key --- docs/book/quick-start.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/book/quick-start.md b/docs/book/quick-start.md index 6bf722568..8f3be0b8e 100644 --- a/docs/book/quick-start.md +++ b/docs/book/quick-start.md @@ -302,12 +302,7 @@ return [ 'Application', '', ], - 'module_listener_options' => [ - 'module_paths' => [ - './module', - './vendor', - ], - ], + // ... other configuration ... ]; ``` From eba83cb76cf4dee717b39f7f9f207f71ce0d95b6 Mon Sep 17 00:00:00 2001 From: Geert Eltink Date: Sat, 12 Sep 2020 10:59:04 +0200 Subject: [PATCH 02/21] Remove branch aliases from package Signed-off-by: Geert Eltink --- composer.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/composer.json b/composer.json index 2e871682d..3acc1e6c1 100644 --- a/composer.json +++ b/composer.json @@ -19,10 +19,6 @@ "sort-packages": true }, "extra": { - "branch-alias": { - "dev-master": "3.1-dev", - "dev-develop": "3.2-dev" - } }, "require": { "php": "^5.6 || ^7.0", From fe10be1070db5de5889171dc1dc371e93e459e84 Mon Sep 17 00:00:00 2001 From: Geert Eltink Date: Sat, 12 Sep 2020 10:59:05 +0200 Subject: [PATCH 03/21] Add automatic-releases workflow Signed-off-by: Geert Eltink --- .../workflows/release-on-milestone-closed.yml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/release-on-milestone-closed.yml diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml new file mode 100644 index 000000000..6066f8b20 --- /dev/null +++ b/.github/workflows/release-on-milestone-closed.yml @@ -0,0 +1,71 @@ +# Alternate workflow example. +# This one is identical to the one in release-on-milestone.yml, with one change: +# the Release step uses the ORGANIZATION_ADMIN_TOKEN instead, to allow it to +# trigger a release workflow event. This is useful if you have other actions +# that intercept that event. + +name: "Automatic Releases" + +on: + milestone: + types: + - "closed" + +jobs: + release: + name: "GIT tag, release & create merge-up PR" + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Release" + uses: "laminas/automatic-releases@v1" + with: + command-name: "laminas:automatic-releases:release" + env: + "GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create Merge-Up Pull Request" + uses: "laminas/automatic-releases@v1" + with: + command-name: "laminas:automatic-releases:create-merge-up-pull-request" + env: + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create and/or Switch to new Release Branch" + uses: "laminas/automatic-releases@v1" + with: + command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor" + env: + "GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Bump Changelog Version On Originating Release Branch" + uses: "laminas/automatic-releases@v1" + with: + command-name: "laminas:automatic-releases:bump-changelog" + env: + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create new milestones" + uses: "laminas/automatic-releases@v1" + with: + command-name: "laminas:automatic-releases:create-milestones" + env: + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} From 50285acd8cc2f4059634d27a6f04975b874db44b Mon Sep 17 00:00:00 2001 From: Geert Eltink Date: Sat, 12 Sep 2020 10:59:05 +0200 Subject: [PATCH 04/21] Update docs deployment workflow Signed-off-by: Geert Eltink --- .github/workflows/docs-build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index 57378fb30..244474298 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -1,9 +1,8 @@ name: docs-build on: - push: - branches: - - master + release: + types: [published] repository_dispatch: types: docs-build @@ -14,4 +13,5 @@ jobs: - name: Build Docs uses: laminas/documentation-theme/github-actions/docs@master env: - DOCS_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }} + "DOCS_DEPLOY_KEY": ${{ secrets.DOCS_DEPLOY_KEY }} + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} From 21961180302b0c97311ee0a27f6bfb59dd27ece7 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Sun, 1 Nov 2020 13:50:01 +0100 Subject: [PATCH 05/21] Initial php8 support Signed-off-by: Witold Wasiczko --- .travis.yml | 31 ++++++++----------------------- composer.json | 4 ++-- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a1e02bce..734b1906d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,48 +12,33 @@ env: matrix: fast_finish: true include: - - php: 5.6 - env: - - DEPS=lowest - - php: 5.6 - env: - - DEPS=latest - - php: 7 + - php: 7.3 env: - DEPS=lowest - - php: 7 + - php: 7.3 env: - DEPS=latest - - php: 7.1 + - php: 7.4 env: - DEPS=lowest - - php: 7.1 + - php: 7.4 env: - DEPS=latest - CS_CHECK=true - TEST_COVERAGE=true - - php: 7.2 + - php: nightly env: - DEPS=lowest - - php: 7.2 - env: - - DEPS=latest - - php: 7.3 - env: - - DEPS=lowest - - php: 7.3 - env: - - DEPS=latest - - php: 7.4 + - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs" + - php: nightly env: - DEPS=latest + - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs" before_install: - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi install: - - travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs - - if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi - if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi diff --git a/composer.json b/composer.json index 3acc1e6c1..7f830c534 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "extra": { }, "require": { - "php": "^5.6 || ^7.0", + "php": "^7.3 || ~8.0.0", "container-interop/container-interop": "^1.2", "laminas/laminas-eventmanager": "^3.2", "laminas/laminas-http": "^2.7", @@ -38,7 +38,7 @@ "laminas/laminas-json": "^2.6.1 || ^3.0", "laminas/laminas-psr7bridge": "^1.0", "laminas/laminas-stratigility": ">=2.0.1 <2.2", - "phpunit/phpunit": "^7.5.18 || ^6.4.4 || ^5.7.14" + "phpunit/phpunit": "^9.4.2" }, "suggest": { "http-interop/http-middleware": "^0.4.1 to be used together with laminas-stratigility", From 5125220463bb463d2ccde694bbf0044e0a6c2cfd Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Sun, 1 Nov 2020 14:00:02 +0100 Subject: [PATCH 06/21] Add missing void retur type for setUp Signed-off-by: Witold Wasiczko --- test/ApplicationTest.php | 2 +- test/Controller/AbstractControllerTest.php | 2 +- test/Controller/ActionControllerTest.php | 2 +- test/Controller/ControllerManagerTest.php | 2 +- test/Controller/IntegrationTest.php | 2 +- test/Controller/LazyControllerAbstractFactoryTest.php | 2 +- test/Controller/MiddlewareControllerTest.php | 2 +- test/Controller/Plugin/AcceptableViewModelSelectorTest.php | 2 +- test/Controller/Plugin/ForwardTest.php | 2 +- test/Controller/Plugin/LayoutTest.php | 2 +- test/Controller/Plugin/ParamsTest.php | 2 +- test/Controller/Plugin/RedirectTest.php | 2 +- test/Controller/Plugin/UrlTest.php | 2 +- test/Controller/RestfulControllerTest.php | 2 +- test/HttpMethodListenerTest.php | 2 +- test/ModuleRouteListenerTest.php | 2 +- test/Service/ControllerManagerFactoryTest.php | 2 +- test/Service/HttpMethodListenerFactoryTest.php | 2 +- test/Service/ServiceListenerFactoryTest.php | 2 +- test/Service/ServiceManagerConfigTest.php | 2 +- test/Service/ViewHelperManagerFactoryTest.php | 2 +- test/View/CreateViewModelListenerTest.php | 2 +- test/View/DefaultRendereringStrategyTest.php | 2 +- test/View/ExceptionStrategyTest.php | 2 +- test/View/InjectTemplateListenerTest.php | 2 +- test/View/InjectViewModelListenerTest.php | 2 +- test/View/RouteNotFoundStrategyTest.php | 2 +- 27 files changed, 27 insertions(+), 27 deletions(-) diff --git a/test/ApplicationTest.php b/test/ApplicationTest.php index e79b1f89f..833badfdc 100644 --- a/test/ApplicationTest.php +++ b/test/ApplicationTest.php @@ -44,7 +44,7 @@ class ApplicationTest extends TestCase */ protected $application; - public function setUp() + public function setUp(): void { $serviceListener = new ServiceListenerFactory(); $r = new ReflectionProperty($serviceListener, 'defaultServiceConfig'); diff --git a/test/Controller/AbstractControllerTest.php b/test/Controller/AbstractControllerTest.php index 5c489f25a..89757bcd5 100644 --- a/test/Controller/AbstractControllerTest.php +++ b/test/Controller/AbstractControllerTest.php @@ -30,7 +30,7 @@ class AbstractControllerTest extends TestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $this->controller = new AbstractControllerStub(); } diff --git a/test/Controller/ActionControllerTest.php b/test/Controller/ActionControllerTest.php index 9e8cf68db..d807a891a 100644 --- a/test/Controller/ActionControllerTest.php +++ b/test/Controller/ActionControllerTest.php @@ -33,7 +33,7 @@ class ActionControllerTest extends TestCase public $request; public $response; - public function setUp() + public function setUp(): void { $this->controller = new SampleController(); $this->request = new Request(); diff --git a/test/Controller/ControllerManagerTest.php b/test/Controller/ControllerManagerTest.php index 72f48263a..71ae4fabb 100644 --- a/test/Controller/ControllerManagerTest.php +++ b/test/Controller/ControllerManagerTest.php @@ -22,7 +22,7 @@ class ControllerManagerTest extends TestCase { - public function setUp() + public function setUp(): void { $this->sharedEvents = new SharedEventManager; $this->events = $this->createEventManager($this->sharedEvents); diff --git a/test/Controller/IntegrationTest.php b/test/Controller/IntegrationTest.php index cb0121074..e24bc9520 100644 --- a/test/Controller/IntegrationTest.php +++ b/test/Controller/IntegrationTest.php @@ -18,7 +18,7 @@ class IntegrationTest extends TestCase { - public function setUp() + public function setUp(): void { $this->sharedEvents = new SharedEventManager(); diff --git a/test/Controller/LazyControllerAbstractFactoryTest.php b/test/Controller/LazyControllerAbstractFactoryTest.php index b8e2b1a45..961aecaba 100644 --- a/test/Controller/LazyControllerAbstractFactoryTest.php +++ b/test/Controller/LazyControllerAbstractFactoryTest.php @@ -16,7 +16,7 @@ class LazyControllerAbstractFactoryTest extends TestCase { - public function setUp() + public function setUp(): void { $this->container = $this->prophesize(ContainerInterface::class); } diff --git a/test/Controller/MiddlewareControllerTest.php b/test/Controller/MiddlewareControllerTest.php index 726dafbed..78199647b 100644 --- a/test/Controller/MiddlewareControllerTest.php +++ b/test/Controller/MiddlewareControllerTest.php @@ -55,7 +55,7 @@ class MiddlewareControllerTest extends TestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $this->pipe = $this->createMock(MiddlewarePipe::class); $this->responsePrototype = $this->createMock(ResponseInterface::class); diff --git a/test/Controller/Plugin/AcceptableViewModelSelectorTest.php b/test/Controller/Plugin/AcceptableViewModelSelectorTest.php index ed39e60b2..72170cc88 100644 --- a/test/Controller/Plugin/AcceptableViewModelSelectorTest.php +++ b/test/Controller/Plugin/AcceptableViewModelSelectorTest.php @@ -19,7 +19,7 @@ class AcceptableViewModelSelectorTest extends TestCase { - public function setUp() + public function setUp(): void { $this->request = new Request(); diff --git a/test/Controller/Plugin/ForwardTest.php b/test/Controller/Plugin/ForwardTest.php index 84008d910..cdb8d0281 100644 --- a/test/Controller/Plugin/ForwardTest.php +++ b/test/Controller/Plugin/ForwardTest.php @@ -54,7 +54,7 @@ class ForwardTest extends TestCase */ private $plugin; - public function setUp() + public function setUp(): void { $eventManager = $this->createEventManager(new SharedEventManager()); $mockApplication = $this->createMock(ApplicationInterface::class); diff --git a/test/Controller/Plugin/LayoutTest.php b/test/Controller/Plugin/LayoutTest.php index 5a3a51492..f9d83e385 100644 --- a/test/Controller/Plugin/LayoutTest.php +++ b/test/Controller/Plugin/LayoutTest.php @@ -17,7 +17,7 @@ class LayoutTest extends TestCase { - public function setUp() + public function setUp(): void { $this->event = $event = new MvcEvent(); $this->controller = new SampleController(); diff --git a/test/Controller/Plugin/ParamsTest.php b/test/Controller/Plugin/ParamsTest.php index c174bc775..d9e47b42b 100644 --- a/test/Controller/Plugin/ParamsTest.php +++ b/test/Controller/Plugin/ParamsTest.php @@ -18,7 +18,7 @@ class ParamsTest extends TestCase { - public function setUp() + public function setUp(): void { $this->request = new Request; $event = new MvcEvent; diff --git a/test/Controller/Plugin/RedirectTest.php b/test/Controller/Plugin/RedirectTest.php index d53a98787..77bacbd80 100644 --- a/test/Controller/Plugin/RedirectTest.php +++ b/test/Controller/Plugin/RedirectTest.php @@ -22,7 +22,7 @@ class RedirectTest extends TestCase { - public function setUp() + public function setUp(): void { $this->response = new Response(); diff --git a/test/Controller/Plugin/UrlTest.php b/test/Controller/Plugin/UrlTest.php index ffbbb3870..a53d13cac 100644 --- a/test/Controller/Plugin/UrlTest.php +++ b/test/Controller/Plugin/UrlTest.php @@ -25,7 +25,7 @@ class UrlTest extends TestCase { - public function setUp() + public function setUp(): void { $router = new SimpleRouteStack; $router->addRoute('home', LiteralRoute::factory([ diff --git a/test/Controller/RestfulControllerTest.php b/test/Controller/RestfulControllerTest.php index 7dea4710e..5ce2e3be5 100644 --- a/test/Controller/RestfulControllerTest.php +++ b/test/Controller/RestfulControllerTest.php @@ -35,7 +35,7 @@ class RestfulControllerTest extends TestCase public $routeMatch; public $event; - public function setUp() + public function setUp(): void { $this->controller = new RestfulTestController(); $this->emptyController = new RestfulMethodNotAllowedTestController(); diff --git a/test/HttpMethodListenerTest.php b/test/HttpMethodListenerTest.php index 6d19100e4..54579b667 100644 --- a/test/HttpMethodListenerTest.php +++ b/test/HttpMethodListenerTest.php @@ -27,7 +27,7 @@ class HttpMethodListenerTest extends TestCase */ protected $listener; - public function setUp() + public function setUp(): void { $this->listener = new HttpMethodListener(); } diff --git a/test/ModuleRouteListenerTest.php b/test/ModuleRouteListenerTest.php index fbba46c8d..8b7c5c800 100644 --- a/test/ModuleRouteListenerTest.php +++ b/test/ModuleRouteListenerTest.php @@ -19,7 +19,7 @@ class ModuleRouteListenerTest extends TestCase { - public function setUp() + public function setUp(): void { $this->request = new Request(); $this->events = new EventManager(); diff --git a/test/Service/ControllerManagerFactoryTest.php b/test/Service/ControllerManagerFactoryTest.php index a646cf94b..e507bb8bb 100644 --- a/test/Service/ControllerManagerFactoryTest.php +++ b/test/Service/ControllerManagerFactoryTest.php @@ -33,7 +33,7 @@ class ControllerManagerFactoryTest extends TestCase */ protected $loader; - public function setUp() + public function setUp(): void { $loaderFactory = new ControllerManagerFactory(); $this->defaultServiceConfig = [ diff --git a/test/Service/HttpMethodListenerFactoryTest.php b/test/Service/HttpMethodListenerFactoryTest.php index 2d20fab85..3a9f4966a 100644 --- a/test/Service/HttpMethodListenerFactoryTest.php +++ b/test/Service/HttpMethodListenerFactoryTest.php @@ -24,7 +24,7 @@ class HttpMethodListenerFactoryTest extends TestCase */ protected $serviceLocator; - public function setUp() + public function setUp(): void { $this->serviceLocator = $this->prophesize(ServiceLocatorInterface::class); $this->serviceLocator->willImplement(ContainerInterface::class); diff --git a/test/Service/ServiceListenerFactoryTest.php b/test/Service/ServiceListenerFactoryTest.php index 9184e720c..9f37a4c34 100644 --- a/test/Service/ServiceListenerFactoryTest.php +++ b/test/Service/ServiceListenerFactoryTest.php @@ -14,7 +14,7 @@ class ServiceListenerFactoryTest extends TestCase { - public function setUp() + public function setUp(): void { $sm = $this->sm = $this->getMockBuilder(ServiceManager::class) ->setMethods(['get']) diff --git a/test/Service/ServiceManagerConfigTest.php b/test/Service/ServiceManagerConfigTest.php index d2f92234b..b1128713a 100644 --- a/test/Service/ServiceManagerConfigTest.php +++ b/test/Service/ServiceManagerConfigTest.php @@ -36,7 +36,7 @@ class ServiceManagerConfigTest extends TestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp(): void { $this->config = new ServiceManagerConfig(); $this->services = new ServiceManager(); diff --git a/test/Service/ViewHelperManagerFactoryTest.php b/test/Service/ViewHelperManagerFactoryTest.php index 2a00ab6b1..381cf4436 100644 --- a/test/Service/ViewHelperManagerFactoryTest.php +++ b/test/Service/ViewHelperManagerFactoryTest.php @@ -21,7 +21,7 @@ class ViewHelperManagerFactoryTest extends TestCase { - public function setUp() + public function setUp(): void { $this->services = new ServiceManager(); $this->factory = new ViewHelperManagerFactory(); diff --git a/test/View/CreateViewModelListenerTest.php b/test/View/CreateViewModelListenerTest.php index bcd20d22b..14fca956f 100644 --- a/test/View/CreateViewModelListenerTest.php +++ b/test/View/CreateViewModelListenerTest.php @@ -20,7 +20,7 @@ class CreateViewModelListenerTest extends TestCase { use EventListenerIntrospectionTrait; - public function setUp() + public function setUp(): void { $this->listener = new CreateViewModelListener(); $this->event = new MvcEvent(); diff --git a/test/View/DefaultRendereringStrategyTest.php b/test/View/DefaultRendereringStrategyTest.php index 8dac04719..e697b4bd0 100644 --- a/test/View/DefaultRendereringStrategyTest.php +++ b/test/View/DefaultRendereringStrategyTest.php @@ -36,7 +36,7 @@ class DefaultRendereringStrategyTest extends TestCase protected $renderer; protected $strategy; - public function setUp() + public function setUp(): void { $this->view = new View(); $this->request = new Request(); diff --git a/test/View/ExceptionStrategyTest.php b/test/View/ExceptionStrategyTest.php index a45e09a03..e522ecceb 100644 --- a/test/View/ExceptionStrategyTest.php +++ b/test/View/ExceptionStrategyTest.php @@ -21,7 +21,7 @@ class ExceptionStrategyTest extends TestCase { use EventListenerIntrospectionTrait; - public function setUp() + public function setUp(): void { $this->strategy = new ExceptionStrategy(); } diff --git a/test/View/InjectTemplateListenerTest.php b/test/View/InjectTemplateListenerTest.php index 8ca2e8d99..76d18b73b 100644 --- a/test/View/InjectTemplateListenerTest.php +++ b/test/View/InjectTemplateListenerTest.php @@ -22,7 +22,7 @@ class InjectTemplateListenerTest extends TestCase { use EventListenerIntrospectionTrait; - public function setUp() + public function setUp(): void { $controllerMap = [ 'MappedNs' => true, diff --git a/test/View/InjectViewModelListenerTest.php b/test/View/InjectViewModelListenerTest.php index 629727a86..5ccfa97a0 100644 --- a/test/View/InjectViewModelListenerTest.php +++ b/test/View/InjectViewModelListenerTest.php @@ -20,7 +20,7 @@ class InjectViewModelListenerTest extends TestCase { use EventListenerIntrospectionTrait; - public function setUp() + public function setUp(): void { $this->listener = new InjectViewModelListener(); $this->event = new MvcEvent(); diff --git a/test/View/RouteNotFoundStrategyTest.php b/test/View/RouteNotFoundStrategyTest.php index 0f485b534..885ca2fdb 100644 --- a/test/View/RouteNotFoundStrategyTest.php +++ b/test/View/RouteNotFoundStrategyTest.php @@ -27,7 +27,7 @@ class RouteNotFoundStrategyTest extends TestCase */ private $strategy; - public function setUp() + public function setUp(): void { $this->strategy = new RouteNotFoundStrategy(); } From c7027bdd426f1a077305a7d9eeed83bf308be3f2 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Mon, 2 Nov 2020 22:40:59 +0100 Subject: [PATCH 07/21] Fixes Signed-off-by: Witold Wasiczko --- composer.json | 2 +- .../ControllerIsDispatchedTest.php | 4 +- ...hableShouldRaiseDispatchErrorEventTest.php | 2 +- ...ntrollerShouldTriggerDispatchErrorTest.php | 4 +- ...veControllerShouldTriggerExceptionTest.php | 4 +- .../InitializationIntegrationTest.php | 6 +- ...llerTypeShouldTriggerDispatchErrorTest.php | 4 +- test/ApplicationTest.php | 22 ++++-- test/Controller/AbstractControllerTest.php | 31 ++++---- test/Controller/ActionControllerTest.php | 8 +- test/Controller/Plugin/ForwardTest.php | 10 +-- test/Controller/RestfulControllerTest.php | 8 +- test/Service/ControllerManagerFactoryTest.php | 4 +- test/Service/ServiceListenerFactoryTest.php | 79 ++++++++++--------- test/Service/ServiceManagerConfigTest.php | 12 +-- test/View/DefaultRendereringStrategyTest.php | 2 +- test/View/ExceptionStrategyTest.php | 2 +- 17 files changed, 108 insertions(+), 96 deletions(-) diff --git a/composer.json b/composer.json index 7f830c534..5ca08f82d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "require-dev": { "http-interop/http-middleware": "^0.4.1", - "laminas/laminas-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "^1.0.0", "laminas/laminas-json": "^2.6.1 || ^3.0", "laminas/laminas-psr7bridge": "^1.0", "laminas/laminas-stratigility": ">=2.0.1 <2.2", diff --git a/test/Application/ControllerIsDispatchedTest.php b/test/Application/ControllerIsDispatchedTest.php index 809c27cd9..4c0350f88 100644 --- a/test/Application/ControllerIsDispatchedTest.php +++ b/test/Application/ControllerIsDispatchedTest.php @@ -20,7 +20,7 @@ public function testControllerIsDispatchedDuringRun() $application = $this->prepareApplication(); $response = $application->run()->getResponse(); - $this->assertContains('PathController', $response->getContent()); - $this->assertContains(MvcEvent::EVENT_DISPATCH, $response->toString()); + $this->assertStringContainsString('PathController', $response->getContent()); + $this->assertStringContainsString(MvcEvent::EVENT_DISPATCH, $response->toString()); } } diff --git a/test/Application/ExceptionsRaisedInDispatchableShouldRaiseDispatchErrorEventTest.php b/test/Application/ExceptionsRaisedInDispatchableShouldRaiseDispatchErrorEventTest.php index 5a6ca713e..39049482b 100644 --- a/test/Application/ExceptionsRaisedInDispatchableShouldRaiseDispatchErrorEventTest.php +++ b/test/Application/ExceptionsRaisedInDispatchableShouldRaiseDispatchErrorEventTest.php @@ -32,6 +32,6 @@ public function testExceptionsRaisedInDispatchableShouldRaiseDispatchErrorEvent( }); $application->run(); - $this->assertContains('Raised an exception', $response->getContent()); + $this->assertStringContainsString('Raised an exception', $response->getContent()); } } diff --git a/test/Application/InabilityToRetrieveControllerShouldTriggerDispatchErrorTest.php b/test/Application/InabilityToRetrieveControllerShouldTriggerDispatchErrorTest.php index 7bfe9b64a..4ee9072f1 100644 --- a/test/Application/InabilityToRetrieveControllerShouldTriggerDispatchErrorTest.php +++ b/test/Application/InabilityToRetrieveControllerShouldTriggerDispatchErrorTest.php @@ -33,7 +33,7 @@ public function testInabilityToRetrieveControllerShouldTriggerDispatchError() }); $application->run(); - $this->assertContains(Application::ERROR_CONTROLLER_NOT_FOUND, $response->getContent()); - $this->assertContains('bad', $response->getContent()); + $this->assertStringContainsString(Application::ERROR_CONTROLLER_NOT_FOUND, $response->getContent()); + $this->assertStringContainsString('bad', $response->getContent()); } } diff --git a/test/Application/InabilityToRetrieveControllerShouldTriggerExceptionTest.php b/test/Application/InabilityToRetrieveControllerShouldTriggerExceptionTest.php index cc5c34ffb..5390354b4 100644 --- a/test/Application/InabilityToRetrieveControllerShouldTriggerExceptionTest.php +++ b/test/Application/InabilityToRetrieveControllerShouldTriggerExceptionTest.php @@ -33,7 +33,7 @@ public function testInabilityToRetrieveControllerShouldTriggerExceptionError() }); $application->run(); - $this->assertContains(Application::ERROR_CONTROLLER_NOT_FOUND, $response->getContent()); - $this->assertContains('bad', $response->getContent()); + $this->assertStringContainsString(Application::ERROR_CONTROLLER_NOT_FOUND, $response->getContent()); + $this->assertStringContainsString('bad', $response->getContent()); } } diff --git a/test/Application/InitializationIntegrationTest.php b/test/Application/InitializationIntegrationTest.php index 2c040de66..effc73fca 100644 --- a/test/Application/InitializationIntegrationTest.php +++ b/test/Application/InitializationIntegrationTest.php @@ -39,8 +39,8 @@ public function testDefaultInitializationWorkflow() $content = ob_get_clean(); $response = $application->getResponse(); - $this->assertContains('Application\\Controller\\PathController', $response->getContent()); - $this->assertContains('Application\\Controller\\PathController', $content); - $this->assertContains(MvcEvent::EVENT_DISPATCH, $response->toString()); + $this->assertStringContainsString('Application\\Controller\\PathController', $response->getContent()); + $this->assertStringContainsString('Application\\Controller\\PathController', $content); + $this->assertStringContainsString(MvcEvent::EVENT_DISPATCH, $response->toString()); } } diff --git a/test/Application/InvalidControllerTypeShouldTriggerDispatchErrorTest.php b/test/Application/InvalidControllerTypeShouldTriggerDispatchErrorTest.php index 6c28b92ac..b13594582 100644 --- a/test/Application/InvalidControllerTypeShouldTriggerDispatchErrorTest.php +++ b/test/Application/InvalidControllerTypeShouldTriggerDispatchErrorTest.php @@ -34,7 +34,7 @@ public function testInvalidControllerTypeShouldTriggerDispatchError() }); $application->run(); - $this->assertContains(Application::ERROR_CONTROLLER_INVALID, $response->getContent()); - $this->assertContains('bad', $response->getContent()); + $this->assertStringContainsString(Application::ERROR_CONTROLLER_INVALID, $response->getContent()); + $this->assertStringContainsString('bad', $response->getContent()); } } diff --git a/test/ApplicationTest.php b/test/ApplicationTest.php index 833badfdc..2e19914a3 100644 --- a/test/ApplicationTest.php +++ b/test/ApplicationTest.php @@ -159,7 +159,14 @@ public function testEventsAreEmptyAtFirst() $sharedEvents = $events->getSharedManager(); $this->assertInstanceOf(SharedEventManager::class, $sharedEvents); - $this->assertAttributeEquals([], 'identifiers', $sharedEvents); + $this->assertSame([], $this->getIdentifiersFromSharedEventManager($sharedEvents)); + } + + private function getIdentifiersFromSharedEventManager(SharedEventManager $events): array + { + $r = new ReflectionProperty($events, 'identifiers'); + $r->setAccessible(true); + return $r->getValue($events); } /** @@ -176,7 +183,6 @@ public function testBootstrapRegistersListeners($listenerServiceName, $event, $m $this->application->bootstrap($isCustom ? (array) $listenerServiceName : []); $events = $this->application->getEventManager(); - $foundListener = false; $listeners = $this->getArrayOfListenersForEvent($event, $events); $this->assertContains([$listenerService, $method], $listeners); } @@ -337,7 +343,7 @@ public function testFinishEventIsTriggeredAfterDispatching() return $e->getResponse()->setContent($e->getResponse()->getBody() . 'foobar'); }); $application->run(); - $this->assertContains( + $this->assertStringContainsString( 'foobar', $this->application->getResponse()->getBody(), 'The "finish" event was not triggered ("foobar" not in response)' @@ -364,7 +370,7 @@ public function testRoutingFailureShouldTriggerDispatchError() $application->run(); $this->assertTrue($event->isError()); - $this->assertContains(Application::ERROR_ROUTER_NO_MATCH, $response->getContent()); + $this->assertStringContainsString(Application::ERROR_ROUTER_NO_MATCH, $response->getContent()); } /** @@ -400,7 +406,7 @@ public function testPhp7ErrorRaisedInDispatchableShouldRaiseDispatchErrorEvent() }); $this->application->run(); - $this->assertContains('Raised an error', $response->getContent()); + $this->assertStringContainsString('Raised an error', $response->getContent()); } /** @@ -483,7 +489,7 @@ public function testApplicationShouldBeEventTargetAtFinishEvent() }); $application->run(); - $this->assertContains(Application::class, $response->getContent()); + $this->assertStringContainsString(Application::class, $response->getContent()); } public function testOnDispatchErrorEventPassedToTriggersShouldBeTheOriginalOne() @@ -501,7 +507,7 @@ public function testOnDispatchErrorEventPassedToTriggersShouldBeTheOriginalOne() } /** - * @group 2981 + * @group #2981 */ public function testReturnsResponseFromListenerWhenRouteEventShortCircuits() { @@ -526,7 +532,7 @@ public function testReturnsResponseFromListenerWhenRouteEventShortCircuits() } /** - * @group 2981 + * @group #2981 */ public function testReturnsResponseFromListenerWhenDispatchEventShortCircuits() { diff --git a/test/Controller/AbstractControllerTest.php b/test/Controller/AbstractControllerTest.php index 89757bcd5..21d6e4df5 100644 --- a/test/Controller/AbstractControllerTest.php +++ b/test/Controller/AbstractControllerTest.php @@ -36,7 +36,7 @@ protected function setUp(): void } /** - * @group 6553 + * @group #6553 */ public function testSetEventManagerWithDefaultIdentifiers() { @@ -46,20 +46,21 @@ public function testSetEventManagerWithDefaultIdentifiers() $eventManager ->expects($this->once()) ->method('setIdentifiers') - ->with($this->logicalNot($this->contains('customEventIdentifier'))); + ->with($this->logicalNot($this->containsEqual('customEventIdentifier'))); $this->controller->setEventManager($eventManager); } /** - * @group 6553 + * @group #6553 */ public function testSetEventManagerWithCustomStringIdentifier() { /* @var $eventManager EventManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ $eventManager = $this->createMock(EventManagerInterface::class); - $eventManager->expects($this->once())->method('setIdentifiers')->with($this->contains('customEventIdentifier')); + $eventManager->expects($this->once())->method('setIdentifiers') + ->with($this->containsEqual('customEventIdentifier')); $reflection = new ReflectionProperty($this->controller, 'eventIdentifier'); @@ -70,7 +71,7 @@ public function testSetEventManagerWithCustomStringIdentifier() } /** - * @group 6553 + * @group #6553 */ public function testSetEventManagerWithMultipleCustomStringIdentifier() { @@ -78,8 +79,8 @@ public function testSetEventManagerWithMultipleCustomStringIdentifier() $eventManager = $this->createMock(EventManagerInterface::class); $eventManager->expects($this->once())->method('setIdentifiers')->with($this->logicalAnd( - $this->contains('customEventIdentifier1'), - $this->contains('customEventIdentifier2') + $this->containsEqual('customEventIdentifier1'), + $this->containsEqual('customEventIdentifier2') )); $reflection = new ReflectionProperty($this->controller, 'eventIdentifier'); @@ -91,7 +92,7 @@ public function testSetEventManagerWithMultipleCustomStringIdentifier() } /** - * @group 6615 + * @group #6615 */ public function testSetEventManagerWithDefaultIdentifiersIncludesImplementedInterfaces() { @@ -102,9 +103,9 @@ public function testSetEventManagerWithDefaultIdentifiersIncludesImplementedInte ->expects($this->once()) ->method('setIdentifiers') ->with($this->logicalAnd( - $this->contains(EventManagerAwareInterface::class), - $this->contains(DispatchableInterface::class), - $this->contains(InjectApplicationEventInterface::class) + $this->containsEqual(EventManagerAwareInterface::class), + $this->containsEqual(DispatchableInterface::class), + $this->containsEqual(InjectApplicationEventInterface::class) )); $this->controller->setEventManager($eventManager); @@ -119,10 +120,10 @@ public function testSetEventManagerWithDefaultIdentifiersIncludesExtendingClassN ->expects($this->once()) ->method('setIdentifiers') ->with($this->logicalAnd( - $this->contains(AbstractController::class), - $this->contains(AbstractControllerStub::class), - $this->contains('LaminasTest'), - $this->contains('LaminasTest\\Mvc\\Controller\\TestAsset') + $this->containsEqual(AbstractController::class), + $this->containsEqual(AbstractControllerStub::class), + $this->containsEqual('LaminasTest'), + $this->containsEqual('LaminasTest\\Mvc\\Controller\\TestAsset') )); $this->controller->setEventManager($eventManager); diff --git a/test/Controller/ActionControllerTest.php b/test/Controller/ActionControllerTest.php index d807a891a..8b4934984 100644 --- a/test/Controller/ActionControllerTest.php +++ b/test/Controller/ActionControllerTest.php @@ -66,7 +66,7 @@ public function testDispatchInvokesNotFoundActionWhenNoActionPresentInRouteMatch $this->assertEquals('content', $result->captureTo()); $vars = $result->getVariables(); $this->assertArrayHasKey('content', $vars, var_export($vars, 1)); - $this->assertContains('Page not found', $vars['content']); + $this->assertStringContainsString('Page not found', $vars['content']); } public function testDispatchInvokesNotFoundActionWhenInvalidActionPresentInRouteMatch() @@ -79,7 +79,7 @@ public function testDispatchInvokesNotFoundActionWhenInvalidActionPresentInRoute $this->assertEquals('content', $result->captureTo()); $vars = $result->getVariables(); $this->assertArrayHasKey('content', $vars, var_export($vars, 1)); - $this->assertContains('Page not found', $vars['content']); + $this->assertStringContainsString('Page not found', $vars['content']); } public function testDispatchInvokesProvidedActionWhenMethodExists() @@ -87,7 +87,7 @@ public function testDispatchInvokesProvidedActionWhenMethodExists() $this->routeMatch->setParam('action', 'test'); $result = $this->controller->dispatch($this->request, $this->response); $this->assertTrue(isset($result['content'])); - $this->assertContains('test', $result['content']); + $this->assertStringContainsString('test', $result['content']); } public function testDispatchCallsActionMethodBasedOnNormalizingAction() @@ -95,7 +95,7 @@ public function testDispatchCallsActionMethodBasedOnNormalizingAction() $this->routeMatch->setParam('action', 'test.some-strangely_separated.words'); $result = $this->controller->dispatch($this->request, $this->response); $this->assertTrue(isset($result['content'])); - $this->assertContains('Test Some Strangely Separated Words', $result['content']); + $this->assertStringContainsString('Test Some Strangely Separated Words', $result['content']); } public function testShortCircuitsBeforeActionIfPreDispatchReturnsAResponse() diff --git a/test/Controller/Plugin/ForwardTest.php b/test/Controller/Plugin/ForwardTest.php index cdb8d0281..70cd03f92 100644 --- a/test/Controller/Plugin/ForwardTest.php +++ b/test/Controller/Plugin/ForwardTest.php @@ -207,7 +207,7 @@ public function testDispatchRaisesDomainExceptionIfCircular() public function testPluginDispatchsRequestedControllerWhenFound() { $result = $this->plugin->dispatch('forward'); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals( ['content' => 'LaminasTest\Mvc\Controller\TestAsset\ForwardController::testAction'], $result @@ -215,7 +215,7 @@ public function testPluginDispatchsRequestedControllerWhenFound() } /** - * @group 5432 + * @group #5432 */ public function testNonArrayListenerDoesNotRaiseErrorWhenPluginDispatchsRequestedController() { @@ -234,7 +234,7 @@ function ($e) {} $event->setApplication($application); $result = $this->plugin->dispatch('forward'); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals( ['content' => 'LaminasTest\Mvc\Controller\TestAsset\ForwardController::testAction'], $result @@ -313,7 +313,7 @@ public function testDispatchWillSeedRouteMatchWithPassedParameters() 'action' => 'test-matches', 'param1' => 'foobar', ]); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertTrue(isset($result['action'])); $this->assertEquals('test-matches', $result['action']); $this->assertTrue(isset($result['param1'])); @@ -341,7 +341,7 @@ public function testRouteMatchObjectRemainsSameFollowingForwardDispatch() public function testAllowsPassingEmptyArrayOfRouteParams() { $result = $this->plugin->dispatch('forward', []); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertTrue(isset($result['status'])); $this->assertEquals('not-found', $result['status']); $this->assertTrue(isset($result['params'])); diff --git a/test/Controller/RestfulControllerTest.php b/test/Controller/RestfulControllerTest.php index 5ce2e3be5..2a0ce7d0f 100644 --- a/test/Controller/RestfulControllerTest.php +++ b/test/Controller/RestfulControllerTest.php @@ -290,7 +290,7 @@ public function testAllowsRegisteringCustomHttpMethodsWithHandlers() $this->request->setMethod('DESCRIBE'); $result = $this->controller->dispatch($this->request, $this->response); $this->assertArrayHasKey('description', $result); - $this->assertContains('::describe', $result['description']); + $this->assertStringContainsString('::describe', $result['description']); } public function testDispatchCallsActionMethodBasedOnNormalizingAction() @@ -298,7 +298,7 @@ public function testDispatchCallsActionMethodBasedOnNormalizingAction() $this->routeMatch->setParam('action', 'test.some-strangely_separated.words'); $result = $this->controller->dispatch($this->request, $this->response); $this->assertArrayHasKey('content', $result); - $this->assertContains('Test Some Strangely Separated Words', $result['content']); + $this->assertStringContainsString('Test Some Strangely Separated Words', $result['content']); } public function testDispatchCallsNotFoundActionWhenActionPassedThatCannotBeMatched() @@ -308,7 +308,7 @@ public function testDispatchCallsNotFoundActionWhenActionPassedThatCannotBeMatch $response = $this->controller->getResponse(); $this->assertEquals(404, $response->getStatusCode()); $this->assertArrayHasKey('content', $result); - $this->assertContains('Page not found', $result['content']); + $this->assertStringContainsString('Page not found', $result['content']); } public function testShortCircuitsBeforeActionIfPreDispatchReturnsAResponse() @@ -419,7 +419,7 @@ public function testParsingDataAsJsonWillReturnAsArray() $this->request->setContent('{"foo":"bar"}'); $result = $this->controller->dispatch($this->request, $this->response); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals(['entity' => ['foo' => 'bar']], $result); } diff --git a/test/Service/ControllerManagerFactoryTest.php b/test/Service/ControllerManagerFactoryTest.php index e507bb8bb..afe319c7b 100644 --- a/test/Service/ControllerManagerFactoryTest.php +++ b/test/Service/ControllerManagerFactoryTest.php @@ -61,12 +61,14 @@ public function testCannotLoadInvalidDispatchable() // Ensure the class exists and can be autoloaded $this->assertTrue(class_exists(InvalidDispatchableClass::class)); + $loader->setFactory(InvalidDispatchableClass::class, InvokableFactory::class); + try { $loader->get(InvalidDispatchableClass::class); $this->fail('Retrieving the invalid dispatchable should fail'); } catch (\Exception $e) { do { - $this->assertNotContains('Should not instantiate this', $e->getMessage()); + $this->assertStringContainsString('Should not instantiate this', $e->getMessage()); } while ($e = $e->getPrevious()); } } diff --git a/test/Service/ServiceListenerFactoryTest.php b/test/Service/ServiceListenerFactoryTest.php index 9f37a4c34..71c9a9d68 100644 --- a/test/Service/ServiceListenerFactoryTest.php +++ b/test/Service/ServiceListenerFactoryTest.php @@ -9,6 +9,7 @@ namespace LaminasTest\Mvc\Service; use Laminas\Mvc\Service\ServiceListenerFactory; +use Laminas\ServiceManager\Exception\ServiceNotCreatedException; use Laminas\ServiceManager\ServiceManager; use PHPUnit\Framework\TestCase; @@ -16,30 +17,25 @@ class ServiceListenerFactoryTest extends TestCase { public function setUp(): void { - $sm = $this->sm = $this->getMockBuilder(ServiceManager::class) + $this->sm = $this->getMockBuilder(ServiceManager::class) ->setMethods(['get']) ->getMock(); $this->factory = new ServiceListenerFactory(); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage The value of service_listener_options must be an array, string given. - */ public function testInvalidOptionType() { $this->sm->expects($this->once()) ->method('get') ->will($this->returnValue(['service_listener_options' => 'string'])); + $this->expectException(ServiceNotCreatedException::class); + $this->expectExceptionMessage("The value of service_listener_options must be an array, string given."); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, 0 array must contain service_manager key. - */ public function testMissingServiceManager() { $config['service_listener_options'][0]['service_manager'] = null; @@ -51,14 +47,14 @@ public function testMissingServiceManager() ->method('get') ->will($this->returnValue($config)); + $this->expectException(ServiceNotCreatedException::class); + $this->expectExceptionMessage( + 'Invalid service listener options detected, 0 array must contain service_manager key.', + ); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, service_manager must be a string, - * integer given. - */ public function testInvalidTypeServiceManager() { $config['service_listener_options'][0]['service_manager'] = 1; @@ -70,13 +66,14 @@ public function testInvalidTypeServiceManager() ->method('get') ->will($this->returnValue($config)); + $this->expectExceptionMessage( + 'Invalid service listener options detected, service_manager must be a string, integer given.', + ); + $this->expectException(ServiceNotCreatedException::class); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, 0 array must contain config_key key. - */ public function testMissingConfigKey() { $config['service_listener_options'][0]['service_manager'] = 'test'; @@ -88,13 +85,14 @@ public function testMissingConfigKey() ->method('get') ->will($this->returnValue($config)); + $this->expectException(ServiceNotCreatedException::class); + $this->expectExceptionMessage( + 'Invalid service listener options detected, 0 array must contain config_key key.', + ); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, config_key must be a string, integer given. - */ public function testInvalidTypeConfigKey() { $config['service_listener_options'][0]['service_manager'] = 'test'; @@ -106,13 +104,14 @@ public function testInvalidTypeConfigKey() ->method('get') ->will($this->returnValue($config)); + $this->expectException(ServiceNotCreatedException::class); + $this->expectExceptionMessage( + 'Invalid service listener options detected, config_key must be a string, integer given.', + ); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, 0 array must contain interface key. - */ public function testMissingInterface() { $config['service_listener_options'][0]['service_manager'] = 'test'; @@ -124,13 +123,12 @@ public function testMissingInterface() ->method('get') ->will($this->returnValue($config)); + $this->expectExceptionMessage("Invalid service listener options detected, 0 array must contain interface key."); + $this->expectException(ServiceNotCreatedException::class); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, interface must be a string, integer given. - */ public function testInvalidTypeInterface() { $config['service_listener_options'][0]['service_manager'] = 'test'; @@ -142,13 +140,14 @@ public function testInvalidTypeInterface() ->method('get') ->will($this->returnValue($config)); + $this->expectExceptionMessage( + 'Invalid service listener options detected, interface must be a string, integer given.', + ); + $this->expectException(ServiceNotCreatedException::class); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, 0 array must contain method key. - */ public function testMissingMethod() { $config['service_listener_options'][0]['service_manager'] = 'test'; @@ -160,13 +159,12 @@ public function testMissingMethod() ->method('get') ->will($this->returnValue($config)); + $this->expectException(ServiceNotCreatedException::class); + $this->expectExceptionMessage("Invalid service listener options detected, 0 array must contain method key."); + $this->factory->__invoke($this->sm, 'ServiceListener'); } - /** - * @expectedException Laminas\ServiceManager\Exception\ServiceNotCreatedException - * @expectedExceptionMessage Invalid service listener options detected, method must be a string, integer given. - */ public function testInvalidTypeMethod() { $config['service_listener_options'][0]['service_manager'] = 'test'; @@ -178,6 +176,11 @@ public function testInvalidTypeMethod() ->method('get') ->will($this->returnValue($config)); + $this->expectExceptionMessage( + 'Invalid service listener options detected, method must be a string, integer given.', + ); + $this->expectException(ServiceNotCreatedException::class); + $this->factory->__invoke($this->sm, 'ServiceListener'); } } diff --git a/test/Service/ServiceManagerConfigTest.php b/test/Service/ServiceManagerConfigTest.php index b1128713a..f34a66f8b 100644 --- a/test/Service/ServiceManagerConfigTest.php +++ b/test/Service/ServiceManagerConfigTest.php @@ -53,7 +53,7 @@ protected function createEventManager(SharedEventManagerInterface $sharedManager } /** - * @group 3786 + * @group #3786 */ public function testEventManagerAwareInterfaceIsNotInjectedIfPresentButSharedManagerIs() { @@ -70,7 +70,7 @@ public function testEventManagerAwareInterfaceIsNotInjectedIfPresentButSharedMan } /** - * @group 6266 + * @group #6266 */ public function testCanMergeCustomConfigWithDefaultConfig() { @@ -94,7 +94,7 @@ public function testCanMergeCustomConfigWithDefaultConfig() } /** - * @group 6266 + * @group #6266 */ public function testCanOverrideDefaultConfigWithCustomConfig() { @@ -119,7 +119,7 @@ public function testCanOverrideDefaultConfigWithCustomConfig() } /** - * @group 6266 + * @group #6266 */ public function testCanAddDelegators() { @@ -153,7 +153,7 @@ public function testCanAddDelegators() } /** - * @group 6266 + * @group #6266 */ public function testEventManagerInitializerCanBeReplaced() { @@ -183,7 +183,7 @@ public function testEventManagerInitializerCanBeReplaced() } /** - * @group 101 + * @group #101 */ public function testCreatesAFactoryForTheServiceManagerThatReturnsIt() { diff --git a/test/View/DefaultRendereringStrategyTest.php b/test/View/DefaultRendereringStrategyTest.php index e697b4bd0..2caeb8618 100644 --- a/test/View/DefaultRendereringStrategyTest.php +++ b/test/View/DefaultRendereringStrategyTest.php @@ -170,6 +170,6 @@ public function testTriggersRenderErrorEventInCaseOfRenderingException() $this->assertTrue($test->flag); $this->assertEquals(Application::ERROR_EXCEPTION, $test->error); $this->assertInstanceOf('Exception', $test->exception); - $this->assertContains('script', $test->exception->getMessage()); + $this->assertStringContainsString('script', $test->exception->getMessage()); } } diff --git a/test/View/ExceptionStrategyTest.php b/test/View/ExceptionStrategyTest.php index e522ecceb..588e632fa 100644 --- a/test/View/ExceptionStrategyTest.php +++ b/test/View/ExceptionStrategyTest.php @@ -88,7 +88,7 @@ public function testCatchesApplicationExceptions() $variables = $model->getVariables(); $this->assertArrayHasKey('message', $variables); - $this->assertContains('error occurred', $variables['message']); + $this->assertStringContainsString('error occurred', $variables['message']); $this->assertArrayHasKey('exception', $variables); $this->assertSame($exception, $variables['exception']); $this->assertArrayHasKey('display_exceptions', $variables); From e7365f947e4cc9fbb22e0cbf0887ea5b84ab28b0 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Mon, 2 Nov 2020 23:03:00 +0100 Subject: [PATCH 08/21] Use working laminas view Signed-off-by: Witold Wasiczko --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5ca08f82d..607ad0ca5 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "laminas/laminas-router": "^3.0.2", "laminas/laminas-servicemanager": "^3.3", "laminas/laminas-stdlib": "^3.2.1", - "laminas/laminas-view": "^2.9", + "laminas/laminas-view": "^2.11.3", "laminas/laminas-zendframework-bridge": "^1.0" }, "require-dev": { From 59c1ab226e5ee2c7e8bd00b29a32a636c3bf8a74 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Mon, 2 Nov 2020 23:21:34 +0100 Subject: [PATCH 09/21] Fix php8 deprecations Signed-off-by: Witold Wasiczko --- .../LazyControllerAbstractFactory.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Controller/LazyControllerAbstractFactory.php b/src/Controller/LazyControllerAbstractFactory.php index b7433b5dc..9f137f6a5 100644 --- a/src/Controller/LazyControllerAbstractFactory.php +++ b/src/Controller/LazyControllerAbstractFactory.php @@ -153,22 +153,22 @@ private function resolveParameter(ContainerInterface $container, $requestedName) * resolved to a service in the container. */ return function (ReflectionParameter $parameter) use ($container, $requestedName) { - if ($parameter->isArray() - && $parameter->getName() === 'config' - && $container->has('config') - ) { - return $container->get('config'); - } - - if ($parameter->isArray()) { + if ($parameter->getType() + && $parameter->getType()->getName() === 'array') + { + if ($parameter->getName() === 'config' + && $container->has('config') + ) { + return $container->get('config'); + } return []; } - if (! $parameter->getClass()) { + if (! $parameter->getType() || $parameter->getType()->isBuiltin()) { return; } - $type = $parameter->getClass()->getName(); + $type = $parameter->getType()->getName(); $type = isset($this->aliases[$type]) ? $this->aliases[$type] : $type; if (! $container->has($type)) { From 86b41b5cee167645cc3aa7ee80661655f723785a Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Mon, 2 Nov 2020 23:24:44 +0100 Subject: [PATCH 10/21] CS fix Signed-off-by: Witold Wasiczko --- src/Controller/LazyControllerAbstractFactory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Controller/LazyControllerAbstractFactory.php b/src/Controller/LazyControllerAbstractFactory.php index 9f137f6a5..7bb09b94c 100644 --- a/src/Controller/LazyControllerAbstractFactory.php +++ b/src/Controller/LazyControllerAbstractFactory.php @@ -154,8 +154,7 @@ private function resolveParameter(ContainerInterface $container, $requestedName) */ return function (ReflectionParameter $parameter) use ($container, $requestedName) { if ($parameter->getType() - && $parameter->getType()->getName() === 'array') - { + && $parameter->getType()->getName() === 'array') { if ($parameter->getName() === 'config' && $container->has('config') ) { From d23cafe94851edc78e0bb551570494ef6a1a0c68 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Tue, 3 Nov 2020 13:03:28 +0100 Subject: [PATCH 11/21] Remove @group annotation with int value Signed-off-by: Witold Wasiczko --- test/ApplicationTest.php | 6 ------ test/Controller/AbstractControllerTest.php | 12 ------------ test/Controller/Plugin/ForwardTest.php | 3 --- test/Service/ServiceManagerConfigTest.php | 18 ------------------ 4 files changed, 39 deletions(-) diff --git a/test/ApplicationTest.php b/test/ApplicationTest.php index 2e19914a3..7dbd6925c 100644 --- a/test/ApplicationTest.php +++ b/test/ApplicationTest.php @@ -506,9 +506,6 @@ public function testOnDispatchErrorEventPassedToTriggersShouldBeTheOriginalOne() $this->assertInstanceOf(ViewModel::class, $event->getResult()); } - /** - * @group #2981 - */ public function testReturnsResponseFromListenerWhenRouteEventShortCircuits() { $this->application->bootstrap(); @@ -531,9 +528,6 @@ public function testReturnsResponseFromListenerWhenRouteEventShortCircuits() $this->assertTrue($triggered); } - /** - * @group #2981 - */ public function testReturnsResponseFromListenerWhenDispatchEventShortCircuits() { $this->application->bootstrap(); diff --git a/test/Controller/AbstractControllerTest.php b/test/Controller/AbstractControllerTest.php index 21d6e4df5..298ce7064 100644 --- a/test/Controller/AbstractControllerTest.php +++ b/test/Controller/AbstractControllerTest.php @@ -35,9 +35,6 @@ protected function setUp(): void $this->controller = new AbstractControllerStub(); } - /** - * @group #6553 - */ public function testSetEventManagerWithDefaultIdentifiers() { /* @var $eventManager EventManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -51,9 +48,6 @@ public function testSetEventManagerWithDefaultIdentifiers() $this->controller->setEventManager($eventManager); } - /** - * @group #6553 - */ public function testSetEventManagerWithCustomStringIdentifier() { /* @var $eventManager EventManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -70,9 +64,6 @@ public function testSetEventManagerWithCustomStringIdentifier() $this->controller->setEventManager($eventManager); } - /** - * @group #6553 - */ public function testSetEventManagerWithMultipleCustomStringIdentifier() { /* @var $eventManager EventManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -91,9 +82,6 @@ public function testSetEventManagerWithMultipleCustomStringIdentifier() $this->controller->setEventManager($eventManager); } - /** - * @group #6615 - */ public function testSetEventManagerWithDefaultIdentifiersIncludesImplementedInterfaces() { /* @var $eventManager EventManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/test/Controller/Plugin/ForwardTest.php b/test/Controller/Plugin/ForwardTest.php index 70cd03f92..cbc572422 100644 --- a/test/Controller/Plugin/ForwardTest.php +++ b/test/Controller/Plugin/ForwardTest.php @@ -214,9 +214,6 @@ public function testPluginDispatchsRequestedControllerWhenFound() ); } - /** - * @group #5432 - */ public function testNonArrayListenerDoesNotRaiseErrorWhenPluginDispatchsRequestedController() { $services = $this->services; diff --git a/test/Service/ServiceManagerConfigTest.php b/test/Service/ServiceManagerConfigTest.php index f34a66f8b..35a59209d 100644 --- a/test/Service/ServiceManagerConfigTest.php +++ b/test/Service/ServiceManagerConfigTest.php @@ -52,9 +52,6 @@ protected function createEventManager(SharedEventManagerInterface $sharedManager return new EventManager($sharedManager ?: $this->services->get('SharedEventManager')); } - /** - * @group #3786 - */ public function testEventManagerAwareInterfaceIsNotInjectedIfPresentButSharedManagerIs() { $events = $this->createEventManager(); @@ -69,9 +66,6 @@ public function testEventManagerAwareInterfaceIsNotInjectedIfPresentButSharedMan $this->assertSame($this->services->get('SharedEventManager'), $events->getSharedManager()); } - /** - * @group #6266 - */ public function testCanMergeCustomConfigWithDefaultConfig() { $custom = [ @@ -93,9 +87,6 @@ public function testCanMergeCustomConfigWithDefaultConfig() $this->assertTrue($sm->has('ModuleManager')); } - /** - * @group #6266 - */ public function testCanOverrideDefaultConfigWithCustomConfig() { $custom = [ @@ -118,9 +109,6 @@ public function testCanOverrideDefaultConfigWithCustomConfig() $this->assertInstanceOf(stdClass::class, $sm->get('ModuleManager')); } - /** - * @group #6266 - */ public function testCanAddDelegators() { /* @@ -152,9 +140,6 @@ public function testCanAddDelegators() $this->assertEquals('baz', $std->bar); } - /** - * @group #6266 - */ public function testEventManagerInitializerCanBeReplaced() { $instance = $this->createMock(EventManagerAwareInterface::class); @@ -182,9 +167,6 @@ public function testEventManagerInitializerCanBeReplaced() $serviceManager->get('EventManagerAware'); } - /** - * @group #101 - */ public function testCreatesAFactoryForTheServiceManagerThatReturnsIt() { $serviceManager = new ServiceManager(); From c5cafcc8b674ff96af90f13d85671c56aa85fd85 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Tue, 3 Nov 2020 13:19:38 +0100 Subject: [PATCH 12/21] Fix prophesize deprecated messages Signed-off-by: Witold Wasiczko --- composer.json | 1 + test/Controller/LazyControllerAbstractFactoryTest.php | 8 ++++++++ test/DispatchListenerTest.php | 3 +++ test/MiddlewareListenerTest.php | 3 +++ test/Service/HttpMethodListenerFactoryTest.php | 3 +++ test/Service/InjectTemplateListenerFactoryTest.php | 3 +++ test/Service/RequestFactoryTest.php | 3 +++ test/Service/ResponseFactoryTest.php | 3 +++ test/Service/SendResponseListenerFactoryTest.php | 3 +++ test/Service/ViewFeedStrategyFactoryTest.php | 3 +++ test/Service/ViewJsonStrategyFactoryTest.php | 3 +++ test/Service/ViewManagerFactoryTest.php | 3 +++ test/Service/ViewPrefixPathStackResolverFactoryTest.php | 3 +++ 13 files changed, 42 insertions(+) diff --git a/composer.json b/composer.json index 607ad0ca5..593137c03 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "laminas/laminas-json": "^2.6.1 || ^3.0", "laminas/laminas-psr7bridge": "^1.0", "laminas/laminas-stratigility": ">=2.0.1 <2.2", + "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.4.2" }, "suggest": { diff --git a/test/Controller/LazyControllerAbstractFactoryTest.php b/test/Controller/LazyControllerAbstractFactoryTest.php index 961aecaba..2a5bf41fd 100644 --- a/test/Controller/LazyControllerAbstractFactoryTest.php +++ b/test/Controller/LazyControllerAbstractFactoryTest.php @@ -13,9 +13,17 @@ use Laminas\ServiceManager\Exception\ServiceNotFoundException; use Laminas\Validator\ValidatorPluginManager; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class LazyControllerAbstractFactoryTest extends TestCase { + use ProphecyTrait; + + /** + * @var ContainerInterface|\Prophecy\Prophecy\ObjectProphecy + */ + private $container; + public function setUp(): void { $this->container = $this->prophesize(ContainerInterface::class); diff --git a/test/DispatchListenerTest.php b/test/DispatchListenerTest.php index f2f5861da..4d18d0f03 100644 --- a/test/DispatchListenerTest.php +++ b/test/DispatchListenerTest.php @@ -20,9 +20,12 @@ use Laminas\Stdlib\ResponseInterface; use Laminas\View\Model\ModelInterface; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class DispatchListenerTest extends TestCase { + use ProphecyTrait; + public function createMvcEvent($controllerMatched) { $response = new Response(); diff --git a/test/MiddlewareListenerTest.php b/test/MiddlewareListenerTest.php index 26a4aeaa3..c0121094a 100644 --- a/test/MiddlewareListenerTest.php +++ b/test/MiddlewareListenerTest.php @@ -26,11 +26,14 @@ use Laminas\Stdlib\DispatchableInterface; use Laminas\View\Model\ModelInterface; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; class MiddlewareListenerTest extends TestCase { + use ProphecyTrait; + /** * @var \Prophecy\Prophecy\ObjectProphecy */ diff --git a/test/Service/HttpMethodListenerFactoryTest.php b/test/Service/HttpMethodListenerFactoryTest.php index 3a9f4966a..b916eab52 100644 --- a/test/Service/HttpMethodListenerFactoryTest.php +++ b/test/Service/HttpMethodListenerFactoryTest.php @@ -13,12 +13,15 @@ use Laminas\ServiceManager\ServiceLocatorInterface; use PHPUnit\Framework\TestCase; use PHPUnit_Framework_MockObject_MockObject as MockObject; +use Prophecy\PhpUnit\ProphecyTrait; /** * @covers Laminas\Mvc\Service\HttpMethodListenerFactory */ class HttpMethodListenerFactoryTest extends TestCase { + use ProphecyTrait; + /** * @var ServiceLocatorInterface|MockObject */ diff --git a/test/Service/InjectTemplateListenerFactoryTest.php b/test/Service/InjectTemplateListenerFactoryTest.php index 11c56628f..3f6487d61 100644 --- a/test/Service/InjectTemplateListenerFactoryTest.php +++ b/test/Service/InjectTemplateListenerFactoryTest.php @@ -14,6 +14,7 @@ use Laminas\Mvc\View\Http\InjectTemplateListener; use Laminas\ServiceManager\ServiceLocatorInterface; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * Tests for {@see \Laminas\Mvc\Service\InjectTemplateListenerFactory} @@ -22,6 +23,8 @@ */ class InjectTemplateListenerFactoryTest extends TestCase { + use ProphecyTrait; + public function testFactoryCanCreateInjectTemplateListener() { $this->buildInjectTemplateListenerWithConfig([]); diff --git a/test/Service/RequestFactoryTest.php b/test/Service/RequestFactoryTest.php index 4b13b7573..0869d3471 100644 --- a/test/Service/RequestFactoryTest.php +++ b/test/Service/RequestFactoryTest.php @@ -12,9 +12,12 @@ use Laminas\Http\Request as HttpRequest; use Laminas\Mvc\Service\RequestFactory; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class RequestFactoryTest extends TestCase { + use ProphecyTrait; + public function testFactoryCreatesHttpRequest() { $factory = new RequestFactory(); diff --git a/test/Service/ResponseFactoryTest.php b/test/Service/ResponseFactoryTest.php index 11523ecae..9ad004758 100644 --- a/test/Service/ResponseFactoryTest.php +++ b/test/Service/ResponseFactoryTest.php @@ -12,9 +12,12 @@ use Laminas\Http\Response as HttpResponse; use Laminas\Mvc\Service\ResponseFactory; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class ResponseFactoryTest extends TestCase { + use ProphecyTrait; + public function testFactoryCreatesHttpResponse() { $factory = new ResponseFactory(); diff --git a/test/Service/SendResponseListenerFactoryTest.php b/test/Service/SendResponseListenerFactoryTest.php index c0c48a7d0..82591b77a 100644 --- a/test/Service/SendResponseListenerFactoryTest.php +++ b/test/Service/SendResponseListenerFactoryTest.php @@ -19,9 +19,12 @@ use Laminas\Mvc\Service\SendResponseListenerFactory; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; class SendResponseListenerFactoryTest extends TestCase { + use ProphecyTrait; + public function testFactoryReturnsListenerWithEventManagerFromContainer() { $sharedEvents = $this->prophesize(SharedEventManagerInterface::class); diff --git a/test/Service/ViewFeedStrategyFactoryTest.php b/test/Service/ViewFeedStrategyFactoryTest.php index c2ec6fce2..ec5df0185 100644 --- a/test/Service/ViewFeedStrategyFactoryTest.php +++ b/test/Service/ViewFeedStrategyFactoryTest.php @@ -13,9 +13,12 @@ use Laminas\View\Renderer\FeedRenderer; use Laminas\View\Strategy\FeedStrategy; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class ViewFeedStrategyFactoryTest extends TestCase { + use ProphecyTrait; + private function createContainer() { $renderer = $this->prophesize(FeedRenderer::class); diff --git a/test/Service/ViewJsonStrategyFactoryTest.php b/test/Service/ViewJsonStrategyFactoryTest.php index e7cf3ff2b..270131080 100644 --- a/test/Service/ViewJsonStrategyFactoryTest.php +++ b/test/Service/ViewJsonStrategyFactoryTest.php @@ -13,9 +13,12 @@ use Laminas\View\Renderer\JsonRenderer; use Laminas\View\Strategy\JsonStrategy; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class ViewJsonStrategyFactoryTest extends TestCase { + use ProphecyTrait; + private function createContainer() { $renderer = $this->prophesize(JsonRenderer::class); diff --git a/test/Service/ViewManagerFactoryTest.php b/test/Service/ViewManagerFactoryTest.php index 804560217..04e1be7f7 100644 --- a/test/Service/ViewManagerFactoryTest.php +++ b/test/Service/ViewManagerFactoryTest.php @@ -12,9 +12,12 @@ use Laminas\Mvc\Service\ViewManagerFactory; use Laminas\Mvc\View\Http\ViewManager as HttpViewManager; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class ViewManagerFactoryTest extends TestCase { + use ProphecyTrait; + private function createContainer() { $http = $this->prophesize(HttpViewManager::class); diff --git a/test/Service/ViewPrefixPathStackResolverFactoryTest.php b/test/Service/ViewPrefixPathStackResolverFactoryTest.php index 8314f3579..f8db763b8 100644 --- a/test/Service/ViewPrefixPathStackResolverFactoryTest.php +++ b/test/Service/ViewPrefixPathStackResolverFactoryTest.php @@ -13,9 +13,12 @@ use Laminas\ServiceManager\ServiceLocatorInterface; use Laminas\View\Resolver\PrefixPathStackResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class ViewPrefixPathStackResolverFactoryTest extends TestCase { + use ProphecyTrait; + public function testCreateService() { $serviceLocator = $this->prophesize(ServiceLocatorInterface::class); From b724b68fcbac2fd5d177b26483a1ad1fce9224dd Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Fri, 27 Nov 2020 09:44:21 +1000 Subject: [PATCH 13/21] Skip MiddlewareListener tests on PHP 8 Stratigility 2 is an EOL optional dependency that does not support PHP 8 Signed-off-by: Aleksei Khudiakov --- test/Controller/MiddlewareControllerTest.php | 3 ++ test/MiddlewareListenerTest.php | 43 ++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/test/Controller/MiddlewareControllerTest.php b/test/Controller/MiddlewareControllerTest.php index 78199647b..ad5a1ead9 100644 --- a/test/Controller/MiddlewareControllerTest.php +++ b/test/Controller/MiddlewareControllerTest.php @@ -24,6 +24,9 @@ /** * @covers \Laminas\Mvc\Controller\MiddlewareController + * + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 */ class MiddlewareControllerTest extends TestCase { diff --git a/test/MiddlewareListenerTest.php b/test/MiddlewareListenerTest.php index c0121094a..8d75d64b9 100644 --- a/test/MiddlewareListenerTest.php +++ b/test/MiddlewareListenerTest.php @@ -79,6 +79,10 @@ public function createMvcEvent($middlewareMatched, $middleware = null) return $event; } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testSuccessfullyDispatchesMiddleware() { $event = $this->createMvcEvent('path', function ($request, $response) { @@ -102,6 +106,10 @@ public function testSuccessfullyDispatchesMiddleware() $this->assertEquals('Test!', $return->getBody()); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testSuccessfullyDispatchesHttpInteropMiddleware() { $expectedOutput = uniqid('expectedOutput', true); @@ -125,6 +133,10 @@ public function testSuccessfullyDispatchesHttpInteropMiddleware() $this->assertEquals($expectedOutput, $return->getBody()); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testMatchedRouteParamsAreInjectedToRequestAsAttributes() { $matchedRouteParam = uniqid('matched param', true); @@ -150,6 +162,10 @@ function (ServerRequestInterface $request, ResponseInterface $response) use (&$r $this->assertSame($this->routeMatch->reveal(), $routeAttribute); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testSuccessfullyDispatchesPipeOfCallableAndHttpInteropStyleMiddlewares() { $response = new Response(); @@ -208,6 +224,10 @@ public function testSuccessfullyDispatchesPipeOfCallableAndHttpInteropStyleMiddl $this->assertEquals('firstMiddlewareValue', $return->getBody()); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testTriggersErrorForUncallableMiddleware() { $event = $this->createMvcEvent('path'); @@ -224,6 +244,10 @@ public function testTriggersErrorForUncallableMiddleware() $this->assertEquals('FAILED', $return); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testTriggersErrorForExceptionRaisedInMiddleware() { $exception = new \Exception(); @@ -245,6 +269,9 @@ public function testTriggersErrorForExceptionRaisedInMiddleware() /** * Ensure that the listener tests for services in abstract factories. + * + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 */ public function testCanLoadFromAbstractFactory() { @@ -287,6 +314,10 @@ function () { $this->assertEquals(TestAsset\Middleware::class, $return->getBody()); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testMiddlewareWithNothingPipedReachesFinalHandlerException() { $response = new Response(); @@ -323,6 +354,10 @@ public function testMiddlewareWithNothingPipedReachesFinalHandlerException() $this->assertEquals('FAILED', $return); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testNullMiddlewareThrowsInvalidMiddlewareException() { $response = new Response(); @@ -358,6 +393,10 @@ public function testNullMiddlewareThrowsInvalidMiddlewareException() $this->assertEquals('FAILED', $return); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testValidMiddlewareDispatchCancelsPreviousDispatchFailures() { $middlewareName = uniqid('middleware', true); @@ -399,6 +438,10 @@ public function testValidMiddlewareDispatchCancelsPreviousDispatchFailures() self::assertEmpty($event->getError(), 'Previously set MVC errors are canceled by a successful dispatch'); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ public function testValidMiddlewareFiresDispatchableInterfaceEventListeners() { $middlewareName = uniqid('middleware', true); From 199ede61021bb2163efddabcc14af8b9856b8bfa Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Fri, 11 Dec 2020 00:33:19 +0100 Subject: [PATCH 14/21] Use stable php 8.0 Signed-off-by: Witold Wasiczko --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 734b1906d..9401c685d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,11 +26,11 @@ matrix: - DEPS=latest - CS_CHECK=true - TEST_COVERAGE=true - - php: nightly + - php: 8.0 env: - DEPS=lowest - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs" - - php: nightly + - php: 8.0 env: - DEPS=latest - COMPOSER_ARGS="--no-interaction --ignore-platform-reqs" From b4e975a32a5d61fc135af3efa3fd66927c2f2be2 Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Mon, 4 May 2020 03:21:49 +1000 Subject: [PATCH 15/21] Deprecate MiddlewareListener Signed-off-by: Aleksei Khudiakov --- composer.json | 6 ++-- src/MiddlewareListener.php | 17 +++++++++-- test/MiddlewareListenerTest.php | 51 +++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 593137c03..483148db1 100644 --- a/composer.json +++ b/composer.json @@ -42,19 +42,17 @@ "phpunit/phpunit": "^9.4.2" }, "suggest": { - "http-interop/http-middleware": "^0.4.1 to be used together with laminas-stratigility", "laminas/laminas-json": "(^2.6.1 || ^3.0) To auto-deserialize JSON body content in AbstractRestfulController extensions, when json_decode is unavailable", "laminas/laminas-log": "^2.9.1 To provide log functionality via LogFilterManager, LogFormatterManager, and LogProcessorManager", "laminas/laminas-mvc-console": "laminas-mvc-console provides the ability to expose laminas-mvc as a console application", "laminas/laminas-mvc-i18n": "laminas-mvc-i18n provides integration with laminas-i18n, including a translation bridge and translatable route segments", + "laminas/laminas-mvc-middleware": "To dispatch middleware in your laminas-mvc application", "laminas/laminas-mvc-plugin-fileprg": "To provide Post/Redirect/Get functionality around forms that container file uploads", "laminas/laminas-mvc-plugin-flashmessenger": "To provide flash messaging capabilities between requests", "laminas/laminas-mvc-plugin-identity": "To access the authenticated identity (per laminas-authentication) in controllers", "laminas/laminas-mvc-plugin-prg": "To provide Post/Redirect/Get functionality within controllers", "laminas/laminas-paginator": "^2.7 To provide pagination functionality via PaginatorPluginManager", - "laminas/laminas-psr7bridge": "(^0.2) To consume PSR-7 middleware within the MVC workflow", - "laminas/laminas-servicemanager-di": "laminas-servicemanager-di provides utilities for integrating laminas-di and laminas-servicemanager in your laminas-mvc application", - "laminas/laminas-stratigility": "(>=2.0.1 <2.2) laminas-stratigility is required to use middleware pipes in the MiddlewareListener" + "laminas/laminas-servicemanager-di": "laminas-servicemanager-di provides utilities for integrating laminas-di and laminas-servicemanager in your laminas-mvc application" }, "autoload": { "psr-4": { diff --git a/src/MiddlewareListener.php b/src/MiddlewareListener.php index b9e23166e..463743a1f 100644 --- a/src/MiddlewareListener.php +++ b/src/MiddlewareListener.php @@ -15,11 +15,18 @@ use Laminas\Mvc\Controller\MiddlewareController; use Laminas\Mvc\Exception\InvalidMiddlewareException; use Laminas\Psr7Bridge\Psr7Response; -use Laminas\Stratigility\Delegate\CallableDelegateDecorator; use Laminas\Stratigility\MiddlewarePipe; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface as PsrResponseInterface; +use function sprintf; +use function trigger_error; + +use const E_USER_DEPRECATED; + +/** + * @deprecated Since 3.2.0 + */ class MiddlewareListener extends AbstractListenerAggregate { /** @@ -52,6 +59,12 @@ public function onDispatch(MvcEvent $event) return; } + trigger_error(sprintf( + 'Dispatching middleware with %s is deprecated since 3.2.0;' + . ' please use laminas/laminas-mvc-middleware package instead', + self::class + ), E_USER_DEPRECATED); + $request = $event->getRequest(); $application = $event->getApplication(); $response = $application->getResponse(); @@ -87,8 +100,6 @@ public function onDispatch(MvcEvent $event) ))->dispatch($request, $response); } catch (\Throwable $ex) { $caughtException = $ex; - } catch (\Exception $ex) { // @TODO clean up once PHP 7 requirement is enforced - $caughtException = $ex; } if ($caughtException !== null) { diff --git a/test/MiddlewareListenerTest.php b/test/MiddlewareListenerTest.php index 8d75d64b9..fee3a7951 100644 --- a/test/MiddlewareListenerTest.php +++ b/test/MiddlewareListenerTest.php @@ -30,6 +30,12 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use function error_reporting; +use function sprintf; +use function var_export; + +use const E_USER_DEPRECATED; + class MiddlewareListenerTest extends TestCase { use ProphecyTrait; @@ -38,6 +44,21 @@ class MiddlewareListenerTest extends TestCase * @var \Prophecy\Prophecy\ObjectProphecy */ private $routeMatch; + /** + * @var int + */ + private $errorReporting; + + protected function setUp(): void + { + $this->errorReporting = error_reporting(); + error_reporting($this->errorReporting & ~E_USER_DEPRECATED); + } + + protected function tearDown(): void + { + error_reporting($this->errorReporting); + } /** * Create an MvcEvent, populated with everything it needs. @@ -106,6 +127,36 @@ public function testSuccessfullyDispatchesMiddleware() $this->assertEquals('Test!', $return->getBody()); } + /** + * Stratigility v2 does not support PHP 8 + * @requires PHP <8 + */ + public function testDispatchingMiddlewareTriggersDeprecation(): void + { + error_reporting($this->errorReporting & E_USER_DEPRECATED); + $this->expectDeprecation(); + $this->expectDeprecationMessage('use laminas/laminas-mvc-middleware'); + + $this->testSuccessfullyDispatchesMiddleware(); + } + + /** + * @doesNotPerformAssertions + */ + public function testDeprecationIsNotTriggeredWhenMiddlewareListenerShortCircuits(): void + { + error_reporting($this->errorReporting & E_USER_DEPRECATED); + + $this->routeMatch = $this->prophesize(RouteMatch::class); + $routeMatch = new RouteMatch(['middleware' => false]); + + $event = new MvcEvent(); + $event->setRouteMatch($routeMatch); + + $listener = new MiddlewareListener(); + $listener->onDispatch($event); + } + /** * Stratigility v2 does not support PHP 8 * @requires PHP <8 From 0adb6f31e7d5801ad6d9ec09cd73b10811640c3c Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Mon, 4 May 2020 04:05:38 +1000 Subject: [PATCH 16/21] Add MiddlewareListener deprecation notice to the docs Signed-off-by: Aleksei Khudiakov --- docs/book/middleware.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/book/middleware.md b/docs/book/middleware.md index df27b2483..5aac00041 100644 --- a/docs/book/middleware.md +++ b/docs/book/middleware.md @@ -18,6 +18,17 @@ is callable. When those conditions are met, it uses the [PSR-7 bridge](https://g to convert the laminas-http request and response objects into PSR-7 instances, and then invokes the middleware. +## Deprecation + +Starting with version 3.2.0 `Laminas\Mvc\MiddlewareListener` is deprecated. +Middleware support is now available via +[laminas-mvc-middleware](https://github.com/laminas/laminas-mvc-middleware) +package, which acts as a drop-in replacement at `^1.0` or provides a PSR-15 +Middleware compatibility starting with `^2.0`. + +`laminas-mvc-middleware` is an MVC module that needs to be registered with +laminas-mvc application to function. + ## Mapping routes to middleware The first step is to map a route to PSR-7 middleware. This looks like any other From 937b6654dab63b7e676864e00933e45c4e170f9a Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Tue, 9 Jun 2020 20:23:41 +1000 Subject: [PATCH 17/21] Provide better documentation for the middleware support Signed-off-by: Aleksei Khudiakov --- docs/book/middleware.md | 170 +++++----------------------------------- 1 file changed, 19 insertions(+), 151 deletions(-) diff --git a/docs/book/middleware.md b/docs/book/middleware.md index 5aac00041..583b85598 100644 --- a/docs/book/middleware.md +++ b/docs/book/middleware.md @@ -5,163 +5,31 @@ and is now being adopted by many frameworks; Laminas itself offers a parallel microframework targeting PSR-7 with [Mezzio](https://docs.mezzio.dev/mezzio). What if you want to dispatch PSR-7 middleware from laminas-mvc? -laminas-mvc currently uses [laminas-http](https://github.com/laminas/laminas-http) +laminas-mvc currently uses [laminas-http](https://docs.laminas.dev/laminas-http/) for its HTTP transport layer, and the objects it defines are not compatible with PSR-7, meaning the basic MVC layer does not and cannot make use of PSR-7 currently. -However, starting with version 2.7.0, laminas-mvc offers -`Laminas\Mvc\MiddlewareListener`. This [dispatch](mvc-event.md#mvceventevent_dispatch-dispatch) -listener listens prior to the default `DispatchListener`, and executes if the -route matches contain a "middleware" parameter, and the service that resolves to -is callable. When those conditions are met, it uses the [PSR-7 bridge](https://github.com/laminas/laminas-psr7bridge) -to convert the laminas-http request and response objects into PSR-7 instances, and -then invokes the middleware. +Package [laminas-mvc-middleware][laminas-mvc-middleware] is a laminas-mvc +application module that enables dispatching of middleware, middleware pipes and +request handlers for the route matches that contain a `middleware` parameter. -## Deprecation +## Built-in Optional Support Deprecation -Starting with version 3.2.0 `Laminas\Mvc\MiddlewareListener` is deprecated. -Middleware support is now available via -[laminas-mvc-middleware](https://github.com/laminas/laminas-mvc-middleware) -package, which acts as a drop-in replacement at `^1.0` or provides a PSR-15 -Middleware compatibility starting with `^2.0`. +Starting with version 2.7.0, laminas-mvc offered now deprecated +`Laminas\Mvc\MiddlewareListener`. MiddlewareListener is always enabled but +requires optional dependencies installed to be used. +Module [laminas-mvc-middleware][laminas-mvc-middleware] transparently replaces +it with `Laminas\Mvc\Middleware\MiddlewareListener` when registered with the +laminas-mvc application. -`laminas-mvc-middleware` is an MVC module that needs to be registered with -laminas-mvc application to function. +Starting with version 3.2.0, built-in `Laminas\Mvc\MiddlewareListener` will +trigger deprecation level errors on an attempt to handle a route match with +`middleware` parameter. -## Mapping routes to middleware +If your application currently depends on the built-in optional middleware +support, `laminas/laminas-mvc-middleware:~1.0.0` provides a drop-in replacement. +Note that module `Laminas\Mvc\Middleware` must be enabled in the laminas-mvc +application. -The first step is to map a route to PSR-7 middleware. This looks like any other -[routing](routing.md) configuration, with one small change: instead of providing -a "controller" in the routing defaults, you provide "middleware": - -```php -// Via configuration: -return [ - 'router' => - 'routes' => [ - 'home' => [ - 'type' => 'literal', - 'options' => [ - 'route' => '/', - 'defaults' => [ - 'middleware' => 'Application\Middleware\IndexMiddleware', - ], - ], - ], - ], - ], -]; - -// Manually: -$route = Literal::factory([ - 'route' => '/', - 'defaults' => [ - 'middleware' => 'Application\Middleware\IndexMiddleware', - ], -]); -``` - -Middleware may be provided as PHP callables, or as service names. - -**As of 3.1.0** you may also specify an `array` of middleware, and middleware -may be [http-interop/http-middleware](https://github.com/http-interop/http-middleware) -compatible. Each item in the array must be a PHP callable, service name, or -http-middleware instance. These will then be piped into a -`Laminas\Stratigility\MiddlewarePipe` instance in the order in which they are -present in the array. - -> ### No action required -> -> Unlike action controllers, middleware typically is single purpose, and, as -> such, does not require a default `action` parameter. - -## Middleware services - -In a normal laminas-mvc dispatch cycle, controllers are pulled from a dedicated -`ControllerManager`. Middleware, however, are pulled from the application -service manager. - -Middleware retrieved *must* be PHP callables. The `MiddlewareListener` will -create an error response if non-callable middleware is indicated. - -## Writing middleware - -Prior to 3.1.0, when dispatching middleware, the `MiddlewareListener` calls it -with two arguments, the PSR-7 request and response, respectively. As such, your -middleware signature should look like the following: - -```php -namespace Application\Middleware; - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; - -class IndexMiddleware -{ - public function __invoke(ServerRequestInterface $request, ResponseInterface $response) - { - // do some work - } -} -``` - -Starting in 3.1.0, the `MiddlewareListener` always adds middleware to a -`Laminas\Stratigility\MiddlewarePipe` instance, and invokes it as -[http-interop/http-middleware](https://github.com/http-interop/http-middleware), -passing it a PSR-7 `ServerRequestInterface` and an http-interop -`DelegateInterface`. - -As such, ideally your middleware should implement the `MiddlewareInterface` from -[http-interop/http-middleware](https://github.com/http-interop/http-middleware): - -```php -namespace Application\Middleware; - -use Interop\Http\ServerMiddleware\DelegateInterface; -use Interop\Http\ServerMiddleware\MiddlewareInterface; -use Psr\Http\Message\ServerRequestInterface; - -class IndexMiddleware implements MiddlewareInterface -{ - public function process(ServerRequestInterface $request, DelegateInterface $delegate) - { - // do some work - } -} -``` - -Alternately, you may still write `callable` middleware using the following -signature: - -```php -function (ServerRequestInterface $request, ResponseInterface $response, callable $next) -{ - // do some work -} -``` - -In the above case, the `DelegateInterface` is decorated as a callable. - -In all versions, within your middleware, you can pull information from the -composed request, and return a response. - -> ### Routing parameters -> -> At the time of the 2.7.0 release, route match parameters were not yet injected -> into the PSR-7 `ServerRequest` instance, and thus not available as request -> attributes. -> -> With the 3.0 release, they are pushed into the PSR-7 `ServerRequest` as -> attributes, and may thus be fetched using -> `$request->getAttribute($attributeName)`. - -## Middleware return values - -Ideally, your middleware should return a PSR-7 response. When it does, it is -converted back to a laminas-http response and returned by the `MiddlewareListener`, -causing the application to short-circuit and return the response immediately. - -You can, however, return arbitrary values. If you do, the result is pushed into -the `MvcEvent` as the event result, allowing later dispatch listeners to -manipulate the results. +[laminas-mvc-middleware]: https://docs.laminas.dev/laminas-mvc-middleware/ From 314d580fb8eb4d31dbab8286678d7c4a9df905e1 Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Fri, 27 Nov 2020 08:16:25 +1000 Subject: [PATCH 18/21] Remove final keyword from InvalidMiddlewareException and deprecate it Signed-off-by: Aleksei Khudiakov --- src/Exception/InvalidMiddlewareException.php | 5 ++++- src/Exception/ReachedFinalHandlerException.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Exception/InvalidMiddlewareException.php b/src/Exception/InvalidMiddlewareException.php index 36062726a..5e9c68ec9 100644 --- a/src/Exception/InvalidMiddlewareException.php +++ b/src/Exception/InvalidMiddlewareException.php @@ -8,7 +8,10 @@ namespace Laminas\Mvc\Exception; -final class InvalidMiddlewareException extends RuntimeException +/** + * @deprecated Since 3.2.0 + */ +class InvalidMiddlewareException extends RuntimeException { /** * @var string diff --git a/src/Exception/ReachedFinalHandlerException.php b/src/Exception/ReachedFinalHandlerException.php index 741073f3b..55cee7492 100644 --- a/src/Exception/ReachedFinalHandlerException.php +++ b/src/Exception/ReachedFinalHandlerException.php @@ -8,6 +8,9 @@ namespace Laminas\Mvc\Exception; +/** + * @deprecated Since 3.2.0 + */ class ReachedFinalHandlerException extends RuntimeException { /** From 241bca664f1c6a4b3ddf7ffdb4a38a6f74831f0b Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Tue, 15 Dec 2020 07:05:52 +1000 Subject: [PATCH 19/21] Apply suggestions from code review Co-authored-by: Matthew Weier O'Phinney Signed-off-by: Aleksei Khudiakov --- docs/book/middleware.md | 24 ++++++++++++------------ src/MiddlewareListener.php | 2 +- test/MiddlewareListenerTest.php | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/book/middleware.md b/docs/book/middleware.md index 583b85598..2fa7dc786 100644 --- a/docs/book/middleware.md +++ b/docs/book/middleware.md @@ -10,26 +10,26 @@ for its HTTP transport layer, and the objects it defines are not compatible with PSR-7, meaning the basic MVC layer does not and cannot make use of PSR-7 currently. -Package [laminas-mvc-middleware][laminas-mvc-middleware] is a laminas-mvc -application module that enables dispatching of middleware, middleware pipes and -request handlers for the route matches that contain a `middleware` parameter. +The package [laminas-mvc-middleware][laminas-mvc-middleware] is a laminas-mvc +application module that enables dispatching of middleware, middleware pipes, and +request handlers for route matches that contain a `middleware` parameter. ## Built-in Optional Support Deprecation -Starting with version 2.7.0, laminas-mvc offered now deprecated -`Laminas\Mvc\MiddlewareListener`. MiddlewareListener is always enabled but +With version 2.7.0, laminas-mvc began offering the now deprecated +`Laminas\Mvc\MiddlewareListener`. The `MiddlewareListener` is always enabled, but requires optional dependencies installed to be used. -Module [laminas-mvc-middleware][laminas-mvc-middleware] transparently replaces -it with `Laminas\Mvc\Middleware\MiddlewareListener` when registered with the +A new laminas-mvc module, [laminas-mvc-middleware][laminas-mvc-middleware], transparently replaces +it with `Laminas\Mvc\Middleware\MiddlewareListener` when registered with a laminas-mvc application. -Starting with version 3.2.0, built-in `Laminas\Mvc\MiddlewareListener` will -trigger deprecation level errors on an attempt to handle a route match with -`middleware` parameter. +Starting with version 3.2.0, the built-in `Laminas\Mvc\MiddlewareListener` will +trigger deprecation level errors on any attempt to handle a route match containing +a `middleware` parameter. If your application currently depends on the built-in optional middleware support, `laminas/laminas-mvc-middleware:~1.0.0` provides a drop-in replacement. -Note that module `Laminas\Mvc\Middleware` must be enabled in the laminas-mvc -application. +If you use this new module, please note that the module `Laminas\Mvc\Middleware` +must be enabled in your laminas-mvc application. [laminas-mvc-middleware]: https://docs.laminas.dev/laminas-mvc-middleware/ diff --git a/src/MiddlewareListener.php b/src/MiddlewareListener.php index 463743a1f..5a6c577c4 100644 --- a/src/MiddlewareListener.php +++ b/src/MiddlewareListener.php @@ -61,7 +61,7 @@ public function onDispatch(MvcEvent $event) trigger_error(sprintf( 'Dispatching middleware with %s is deprecated since 3.2.0;' - . ' please use laminas/laminas-mvc-middleware package instead', + . ' please use the laminas/laminas-mvc-middleware package instead', self::class ), E_USER_DEPRECATED); diff --git a/test/MiddlewareListenerTest.php b/test/MiddlewareListenerTest.php index fee3a7951..ffc45636a 100644 --- a/test/MiddlewareListenerTest.php +++ b/test/MiddlewareListenerTest.php @@ -135,7 +135,7 @@ public function testDispatchingMiddlewareTriggersDeprecation(): void { error_reporting($this->errorReporting & E_USER_DEPRECATED); $this->expectDeprecation(); - $this->expectDeprecationMessage('use laminas/laminas-mvc-middleware'); + $this->expectDeprecationMessage('use the laminas/laminas-mvc-middleware package'); $this->testSuccessfullyDispatchesMiddleware(); } From d639b1c5274227593aebc1905d43796d808e06c8 Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Tue, 15 Dec 2020 07:49:44 +1000 Subject: [PATCH 20/21] 3.2.0 release readiness Signed-off-by: Aleksei Khudiakov --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a5804fd8..35b3b8f31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,18 +6,18 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- [zendframework/zend-mvc#297](https://github.com/zendframework/zend-mvc/pull/297) adds support for PHP 7.3. +- [#69](https://github.com/laminas/laminas-mvc/pull/69) Adds PHP 8.0 support - [zendframework/zend-mvc#282](https://github.com/zendframework/zend-mvc/pull/282) Adds a full controller namespace as additional event manager identifier for implementations of AbstractController ### Deprecated -- Nothing. +- [#51](https://github.com/laminas/laminas-mvc/pull/51) Deprecates MiddlewareListener. Optional support for dispatching middleware, middleware pipes and handlers is moved to laminas/laminas-mvc-middleware package ### Removed -- Nothing. +- [#69](https://github.com/laminas/laminas-mvc/pull/69) Removes PHP support prior 7.3.0 ### Fixed From 88da7200cf8f5a970c35d91717a5c4db94981e5e Mon Sep 17 00:00:00 2001 From: Laminas Bot Date: Mon, 14 Dec 2020 21:54:40 +0000 Subject: [PATCH 21/21] 3.2.0 readiness Updates the CHANGELOG.md to set the release date. --- CHANGELOG.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35b3b8f31..bbe7b7ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 3.2.0 - TBD +## 3.2.0 - 2020-12-14 ### Added @@ -19,9 +19,24 @@ All notable changes to this project will be documented in this file, in reverse - [#69](https://github.com/laminas/laminas-mvc/pull/69) Removes PHP support prior 7.3.0 -### Fixed -- Nothing. +----- + +### Release Notes for [3.2.0](https://github.com/laminas/laminas-mvc/milestone/1) + + + +### 3.2.0 + +- Total issues resolved: **0** +- Total pull requests resolved: **2** +- Total contributors: **2** + +#### Enhancement + + - [69: PHP 8.0 support](https://github.com/laminas/laminas-mvc/pull/69) thanks to @snapshotpl + + - [51: Deprecate middleware listener](https://github.com/laminas/laminas-mvc/pull/51) thanks to @Xerkus ## 3.1.1 - 2017-11-24