From 82225fb5a28341b43bba9385a2caaed76a3cf38a Mon Sep 17 00:00:00 2001 From: OStefan2001 Date: Fri, 27 Nov 2026 09:50:27 +0200 Subject: [PATCH 1/2] updated codebase, composer, workflow and tests --- .github/workflows/codecov.yml | 8 ++++---- .github/workflows/static-analysis.yml | 6 +++--- composer.json | 4 ++-- phpunit.xml | 2 +- test/AbstractActionControllerTest.php | 4 ++-- test/AbstractControllerTest.php | 8 +++++--- .../ControllerEventListenersInitializerTest.php | 10 +++++----- test/Factory/PluginManagerAwareInitializerTest.php | 4 +++- test/Factory/PluginManagerFactoryTest.php | 6 +++--- test/Plugin/PluginManagerTest.php | 4 ++-- test/Plugin/TemplatePluginTest.php | 2 ++ test/Plugin/UrlHelperPluginTest.php | 2 ++ 12 files changed, 34 insertions(+), 26 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 89e83df..5cd87b3 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -15,14 +15,14 @@ jobs: - ubuntu-latest php: - - "8.2" - "8.3" - "8.4" - "8.5" + - "8.6" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -36,7 +36,7 @@ jobs: run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - name: Cache dependencies installed with composer - uses: actions/cache@v3 + uses: actions/cache@v6 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} @@ -49,6 +49,6 @@ jobs: run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml - name: Send code coverage report to Codecov.io - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9976515..2763b9c 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,14 +15,14 @@ jobs: - ubuntu-latest php: - - "8.2" - "8.3" - "8.4" - "8.5" + - "8.6" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -36,7 +36,7 @@ jobs: run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - name: Cache dependencies installed with composer - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/composer.json b/composer.json index be6ee33..0e73e15 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "dotkernel/dot-event": "^4.0.0", "laminas/laminas-servicemanager": "^4.0", "mezzio/mezzio-helpers": "^5.8.0", @@ -30,7 +30,7 @@ "laminas/laminas-diactoros": "^3.0", "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^10.2" + "phpunit/phpunit": "^12.5.22" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 5302ca2..7a63339 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + ./test diff --git a/test/AbstractActionControllerTest.php b/test/AbstractActionControllerTest.php index 831e888..748634b 100644 --- a/test/AbstractActionControllerTest.php +++ b/test/AbstractActionControllerTest.php @@ -20,7 +20,7 @@ class AbstractActionControllerTest extends TestCase public function testNonExistingActionWillReturnResponse(): void { $request = $this->createMock(ServerRequestInterface::class); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = $this->createStub(RequestHandlerInterface::class); $request->expects($this->any())->method('getAttribute')->withAnyParameters()->willReturn('test'); @@ -37,7 +37,7 @@ public function testNonExistingActionWillReturnResponse(): void public function testExistingActionWillReturnResponse(): void { $request = $this->createMock(ServerRequestInterface::class); - $handler = $this->createMock(RequestHandlerInterface::class); + $handler = $this->createStub(RequestHandlerInterface::class); $request->expects($this->any())->method('getAttribute')->withAnyParameters()->willReturn('index'); diff --git a/test/AbstractControllerTest.php b/test/AbstractControllerTest.php index 3498e42..41429c3 100644 --- a/test/AbstractControllerTest.php +++ b/test/AbstractControllerTest.php @@ -9,6 +9,7 @@ use Dot\Controller\Plugin\PluginInterface; use Dot\Controller\Plugin\PluginManager; use Laminas\Diactoros\Response; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -16,6 +17,7 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; +#[AllowMockObjectsWithoutExpectations] class AbstractControllerTest extends TestCase { private PluginManager|MockObject $pluginManager; @@ -30,9 +32,9 @@ class AbstractControllerTest extends TestCase public function setUp(): void { $this->pluginManager = $this->createMock(PluginManager::class); - $this->plugin = $this->createMock(PluginInterface::class); - $this->request = $this->createMock(ServerRequestInterface::class); - $this->handler = $this->createMock(RequestHandlerInterface::class); + $this->plugin = $this->createStub(PluginInterface::class); + $this->request = $this->createStub(ServerRequestInterface::class); + $this->handler = $this->createStub(RequestHandlerInterface::class); $this->subject = new class extends Subject { public function dispatch(): ResponseInterface { diff --git a/test/Factory/ControllerEventListenersInitializerTest.php b/test/Factory/ControllerEventListenersInitializerTest.php index 358120a..c5cc76c 100644 --- a/test/Factory/ControllerEventListenersInitializerTest.php +++ b/test/Factory/ControllerEventListenersInitializerTest.php @@ -10,6 +10,7 @@ use Laminas\EventManager\EventManager; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -18,7 +19,7 @@ class ControllerEventListenersInitializerTest extends TestCase { private ContainerInterface|MockObject $container; - private AbstractController|MockObject $controller; + private AbstractController|Stub $controller; private EventManager|MockObject $eventManager; private Subject $subject; @@ -28,7 +29,7 @@ class ControllerEventListenersInitializerTest extends TestCase public function setUp(): void { $this->container = $this->createMock(ContainerInterface::class); - $this->controller = $this->createMock(AbstractController::class); + $this->controller = $this->createStub(AbstractController::class); $this->eventManager = $this->createMock(EventManager::class); $this->subject = new Subject(); } @@ -61,8 +62,8 @@ public function testAttachControllerListeners(): void ]); $this->container->method('get')->willReturnMap([ - ['ListenerClass1', $this->createMock(ControllerEventListenerInterface::class)], - ['ListenerClass2', $this->createMock(ControllerEventListenerInterface::class)], + ['ListenerClass1', $this->createStub(ControllerEventListenerInterface::class)], + ['ListenerClass2', $this->createStub(ControllerEventListenerInterface::class)], ]); $this->controller->method('getEventManager')->willReturn($this->eventManager); @@ -72,7 +73,6 @@ public function testAttachControllerListeners(): void $this->eventManager->expects($this->any())->method('attach') ->with($this->isInstanceOf(ControllerEventListenerInterface::class), 1); - $this->expectNotToPerformAssertions(); $this->subject->attachControllerListeners($this->container, $this->controller); } } diff --git a/test/Factory/PluginManagerAwareInitializerTest.php b/test/Factory/PluginManagerAwareInitializerTest.php index bab017c..31e171a 100644 --- a/test/Factory/PluginManagerAwareInitializerTest.php +++ b/test/Factory/PluginManagerAwareInitializerTest.php @@ -9,6 +9,7 @@ use Dot\Controller\Plugin\PluginManager; use Dot\Controller\Plugin\PluginManagerAwareInterface; use Laminas\Diactoros\Response; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -30,7 +31,7 @@ public function setUp(): void { $this->subject = new Subject(); $this->container = $this->createMock(ContainerInterface::class); - $this->pluginManager = $this->createMock(PluginManager::class); + $this->pluginManager = $this->createStub(PluginManager::class); } /** @@ -58,6 +59,7 @@ public function testInvokeSetsPluginManagerWhenInstanceIsPluginManagerAwareInter * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ + #[AllowMockObjectsWithoutExpectations] public function testInvokeSetsDebugFlagWhenInstanceIsAbstractController(): void { $this->container->method('get') diff --git a/test/Factory/PluginManagerFactoryTest.php b/test/Factory/PluginManagerFactoryTest.php index 1d3c2b1..0c5bf15 100644 --- a/test/Factory/PluginManagerFactoryTest.php +++ b/test/Factory/PluginManagerFactoryTest.php @@ -30,9 +30,9 @@ class PluginManagerFactoryTest extends TestCase public function setUp(): void { $this->subject = new Subject(); - $this->container = $this->createMock(ContainerInterface::class); - $this->templateRenderer = $this->createMock(TemplateRendererInterface::class); - $this->urlHelper = $this->createMock(UrlHelper::class); + $this->container = $this->createStub(ContainerInterface::class); + $this->templateRenderer = $this->createStub(TemplateRendererInterface::class); + $this->urlHelper = $this->createStub(UrlHelper::class); } /** diff --git a/test/Plugin/PluginManagerTest.php b/test/Plugin/PluginManagerTest.php index 9d2429f..a6674c7 100644 --- a/test/Plugin/PluginManagerTest.php +++ b/test/Plugin/PluginManagerTest.php @@ -23,7 +23,7 @@ class PluginManagerTest extends TestCase */ protected function setup(): void { - $this->container = $this->createMock(ContainerInterface::class); + $this->container = $this->createStub(ContainerInterface::class); $this->subject = new Subject($this->container); } @@ -33,7 +33,7 @@ protected function setup(): void */ public function testInstanceOf(): void { - $plugin = $this->createMock(PluginInterface::class); + $plugin = $this->createStub(PluginInterface::class); $this->expectNotToPerformAssertions(); $this->subject->validate($plugin); } diff --git a/test/Plugin/TemplatePluginTest.php b/test/Plugin/TemplatePluginTest.php index e3cdbe6..66279cc 100644 --- a/test/Plugin/TemplatePluginTest.php +++ b/test/Plugin/TemplatePluginTest.php @@ -6,6 +6,7 @@ use Dot\Controller\Plugin\TemplatePlugin as Subject; use Mezzio\Template\TemplateRendererInterface; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -24,6 +25,7 @@ protected function setup(): void $this->subject = new Subject($this->templateRenderer); } + #[AllowMockObjectsWithoutExpectations] public function testInvokeWithoutArguments(): void { $result = $this->subject->__invoke(); diff --git a/test/Plugin/UrlHelperPluginTest.php b/test/Plugin/UrlHelperPluginTest.php index 718efe7..f47a68c 100644 --- a/test/Plugin/UrlHelperPluginTest.php +++ b/test/Plugin/UrlHelperPluginTest.php @@ -6,6 +6,7 @@ use Dot\Controller\Plugin\UrlHelperPlugin as Subject; use Mezzio\Helper\UrlHelper; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -24,6 +25,7 @@ public function setUp(): void $this->subject = new Subject($this->urlHelper); } + #[AllowMockObjectsWithoutExpectations] public function testInvokeWithoutArguments(): void { $result = $this->subject->__invoke(); From 7bf1bac88661bb68ca42e06699f3c8ad90468da2 Mon Sep 17 00:00:00 2001 From: OStefan2001 Date: Fri, 27 Nov 2026 16:56:01 +0200 Subject: [PATCH 2/2] updated overview and readme --- README.md | 4 ++-- docs/book/v4/overview.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 53dc995..b0d2d27 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Documentation is available at: https://docs.dotkernel.org/dot-controller/. [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/blob/4.0/LICENSE.md) -[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml) +[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller) -[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml) +[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml) ## Installation diff --git a/docs/book/v4/overview.md b/docs/book/v4/overview.md index bb82c52..6ff64ba 100644 --- a/docs/book/v4/overview.md +++ b/docs/book/v4/overview.md @@ -14,6 +14,6 @@ It is more lightweight, though, but supports controller plugins and event listen [![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/stargazers) [![GitHub license](https://img.shields.io/github/license/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/blob/4.0/LICENSE.md) -[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml) +[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller) -[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml) +[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.x)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)