diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4317b80..4907339 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,10 +12,10 @@ jobs: strategy: matrix: - php-version: ['8.1'] + php-version: ['8.2', '8.3'] dependencies: [''] include: - - { php-version: '8.1', dependencies: '--prefer-lowest --prefer-stable' } + - { php-version: '8.2', dependencies: '--prefer-lowest --prefer-stable' } name: Unit tests - PHP ${{ matrix.dependencies }} @@ -65,7 +65,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' extensions: json, mbstring - name: Install dependencies diff --git a/CHANGELOG.md b/CHANGELOG.md index bb1ff03..c590d2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Unreleased +- Drop support for php 8.1 +- Add support for Symfon 7 +- Update dependencies ## 2.0.0 - 2022-05-06 - Require php 8.1 diff --git a/composer.json b/composer.json index 41f13d5..b43e366 100644 --- a/composer.json +++ b/composer.json @@ -4,31 +4,31 @@ "license": "MIT", "type": "symfony-bundle", "require": { - "php": "^8.1", + "php": "^8.2", "ext-json": "*", "ext-mbstring": "*", - "lmc/cqrs-handler": "^2.0", - "lmc/cqrs-types": "^3.0", - "symfony/config": "^5.2 || ^6.0", - "symfony/console": "^5.2 || ^6.0", - "symfony/dependency-injection": "^5.2 || ^6.0", - "symfony/error-handler": "^5.2 || ^6.0", - "symfony/framework-bundle": "^5.2 || ^6.0", - "symfony/http-foundation": "^5.2 || ^6.0", - "symfony/http-kernel": "^5.2 || ^6.0", + "lmc/cqrs-handler": "^2.2", + "lmc/cqrs-types": "^3.2", + "symfony/config": "^5.2 || ^6.0 || ^7.0", + "symfony/console": "^5.2 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.2 || ^6.0 || ^7.0", + "symfony/error-handler": "^5.2 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.2 || ^6.0 || ^7.0", + "symfony/http-foundation": "^5.2 || ^6.0 || ^7.0", + "symfony/http-kernel": "^5.2 || ^6.0 || ^7.0", "twig/twig": "^2.0 || ^3.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.5", "lmc/coding-standard": "^3.3", - "lmc/cqrs-http": "^3.0", - "lmc/cqrs-solr": "^3.0", + "lmc/cqrs-http": "^3.1", + "lmc/cqrs-solr": "^3.1", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.6", "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5.20", - "symfony/yaml": "^5.2 || ^6.0" + "phpunit/phpunit": "^11.0.4", + "symfony/yaml": "^5.2 || ^6.0 || ^7.0" }, "suggest": { "lmc/cqrs-http": "Provides http handler and base types for queries and commands.", @@ -46,9 +46,9 @@ }, "config": { "allow-plugins": { - "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true, "ergebnis/composer-normalize": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "phpstan/extension-installer": true }, "sort-packages": true }, diff --git a/phpstan.neon b/phpstan.neon index 40de399..b4df7cf 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,3 +9,4 @@ parameters: - src/DependencyInjection/Configuration.php ignoreErrors: + - '#.*and class-string\|null will always evaluate to false.*#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4365213..eae919d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,38 +1,33 @@ - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" colors="true" + bootstrap="vendor/autoload.php"> - - src - - - src/Command - src/Controller - - - tests/ - + + + src + + + src/Command + src/Controller + + diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 6d89431..eb7a2a2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -8,7 +8,7 @@ class Configuration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('lmc_cqrs'); $treeBuilder->getRootNode() diff --git a/tests/DependencyInjection/Compiler/HandlerPassTest.php b/tests/DependencyInjection/Compiler/HandlerPassTest.php index a93a24b..4044eaa 100644 --- a/tests/DependencyInjection/Compiler/HandlerPassTest.php +++ b/tests/DependencyInjection/Compiler/HandlerPassTest.php @@ -5,13 +5,12 @@ use Lmc\Cqrs\Bundle\AbstractTestCase; use Lmc\Cqrs\Types\CommandSenderInterface; use Lmc\Cqrs\Types\QueryFetcherInterface; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\DependencyInjection\ContainerBuilder; class HandlerPassTest extends AbstractTestCase { - /** - * @test - */ + #[Test] public function shouldSetUpQueryFetcher(): void { $container = new ContainerBuilder(); @@ -41,9 +40,7 @@ public function shouldSetUpQueryFetcher(): void $this->assertCalledMethods($expectedMethods, $methodCalls); } - /** - * @test - */ + #[Test] public function shouldSetUpCommandSender(): void { $container = new ContainerBuilder(); diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 7660908..1213f75 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -3,13 +3,12 @@ namespace Lmc\Cqrs\Bundle\DependencyInjection; use Lmc\Cqrs\Bundle\AbstractTestCase; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper; class ConfigurationTest extends AbstractTestCase { - /** - * @test - */ + #[Test] public function configurationDefinition(): void { $dumper = new YamlReferenceDumper(); diff --git a/tests/DependencyInjection/LmcCqrsExtensionTest.php b/tests/DependencyInjection/LmcCqrsExtensionTest.php index 63358fe..76bde6e 100644 --- a/tests/DependencyInjection/LmcCqrsExtensionTest.php +++ b/tests/DependencyInjection/LmcCqrsExtensionTest.php @@ -41,6 +41,8 @@ use Lmc\Cqrs\Types\QueryFetcherInterface; use Lmc\Cqrs\Types\QueryHandlerInterface; use Lmc\Cqrs\Types\SendCommandHandlerInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\DependencyInjection\ContainerBuilder; class LmcCqrsExtensionTest extends AbstractTestCase @@ -56,9 +58,7 @@ protected function setUp(): void $this->containerBuilder->registerExtension($this->extension); } - /** - * @test - */ + #[Test] public function shouldSetUpDefaultServices(): void { $configs = []; @@ -180,9 +180,7 @@ private function assertNoSolrExtensionSettings(ContainerBuilder $containerBuilde } } - /** - * @test - */ + #[Test] public function shouldSetUpCacheForServices(): void { $configs = [ @@ -221,9 +219,7 @@ private function assertCacheSettings( $this->assertSame('cache_class', $containerBuilder->findDefinition('lmc_cqrs.cache_provider')->getClass()); } - /** - * @test - */ + #[Test] public function shouldSetUpAllServices(): void { $configs = [ @@ -253,10 +249,8 @@ public function shouldSetUpAllServices(): void $this->assertSolrExtensionSettings($this->containerBuilder); } - /** - * @test - * @dataProvider provideProfilerConfigs - */ + #[Test] + #[DataProvider('provideProfilerConfigs')] public function shouldSetUpServicesForProfiler(array $config): void { $configs = [$config]; @@ -276,7 +270,7 @@ public function shouldSetUpServicesForProfiler(array $config): void ); } - public function provideProfilerConfigs(): array + public static function provideProfilerConfigs(): array { return [ // config @@ -317,9 +311,7 @@ private function assertProfilerSettings(ContainerBuilder $containerBuilder): voi ); } - /** - * @test - */ + #[Test] public function shouldSetUpServicesForProfilerWithVerbosity(): void { $configs = [ @@ -350,9 +342,7 @@ public function shouldSetUpServicesForProfilerWithVerbosity(): void $this->assertSame(ProfilerBag::VERBOSITY_DEBUG, $profilerBag->getVerbosity()); } - /** - * @test - */ + #[Test] public function shouldSetUpServicesForDebug(): void { $configs = [ @@ -389,9 +379,7 @@ private function assertDebugSettings(ContainerBuilder $containerBuilder): void } } - /** - * @test - */ + #[Test] public function shouldSetUpServicesForHttpExtension(): void { $configs = [ @@ -441,9 +429,7 @@ private function assertHttpExtensionSettings(ContainerBuilder $containerBuilder) ); } - /** - * @test - */ + #[Test] public function shouldSetUpServicesForSolrExtension(): void { $configs = [ diff --git a/tests/LmcCqrsBundleTest.php b/tests/LmcCqrsBundleTest.php index 66f3e72..c81c438 100644 --- a/tests/LmcCqrsBundleTest.php +++ b/tests/LmcCqrsBundleTest.php @@ -3,13 +3,12 @@ namespace Lmc\Cqrs\Bundle; use Lmc\Cqrs\Bundle\DependencyInjection\Compiler\HandlerPass; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\DependencyInjection\ContainerBuilder; class LmcCqrsBundleTest extends AbstractTestCase { - /** - * @test - */ + #[Test] public function shouldSetUpHandlerPass(): void { $containerBuilder = new ContainerBuilder(); diff --git a/tests/Profiler/CqrsDataCollectorTest.php b/tests/Profiler/CqrsDataCollectorTest.php index 6e54440..c67a533 100644 --- a/tests/Profiler/CqrsDataCollectorTest.php +++ b/tests/Profiler/CqrsDataCollectorTest.php @@ -16,6 +16,8 @@ use Lmc\Cqrs\Types\ValueObject\CacheKey; use Lmc\Cqrs\Types\ValueObject\FormattedValue; use Lmc\Cqrs\Types\ValueObject\ProfilerItem; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Test; use Ramsey\Uuid\Uuid; use Symfony\Component\ErrorHandler\Exception\FlattenException; use Symfony\Component\HttpFoundation\Request; @@ -34,9 +36,7 @@ protected function setUp(): void $this->commandSender = new CommandSender(null); } - /** - * @test - */ + #[Test] public function shouldGetDefaultFormattersPriority(): void { $this->assertSame(0, CqrsDataCollector::getDefaultPriority()); @@ -77,9 +77,7 @@ private function setUpCollectorWithData( ); } - /** - * @test - */ + #[Test] public function shouldCollectsQueriesAndCommands(): CqrsDataCollector { $queries = [ @@ -162,11 +160,8 @@ public function shouldCollectsQueriesAndCommands(): CqrsDataCollector return $collector; } - /** - * @depends shouldCollectsQueriesAndCommands - * - * @test - */ + #[Test] + #[Depends('shouldCollectsQueriesAndCommands')] public function shouldResetCollectedQueries(CqrsDataCollector $collector): void { $collector->reset(); @@ -181,9 +176,7 @@ public function shouldResetCollectedQueries(CqrsDataCollector $collector): void $this->assertEmpty($collector->getRegisteredFormatters()); } - /** - * @test - */ + #[Test] public function countsCachedAndUncachedQueries(): void { $queries = [ @@ -233,9 +226,7 @@ public function countsCachedAndUncachedQueries(): void $this->assertSame(1, $collector->countUncachedQueries()); } - /** - * @test - */ + #[Test] public function shouldFormatCollectedItems(): void { $error = new \Exception('error message'); diff --git a/tests/Service/ClassExtensionTest.php b/tests/Service/ClassExtensionTest.php index 182677d..84b7246 100644 --- a/tests/Service/ClassExtensionTest.php +++ b/tests/Service/ClassExtensionTest.php @@ -2,6 +2,8 @@ namespace Lmc\Cqrs\Bundle\Service; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class ClassExtensionTest extends TestCase @@ -13,10 +15,8 @@ protected function setUp(): void $this->extension = new ClassExtension(); } - /** - * @test - * @dataProvider provideClass - */ + #[Test] + #[DataProvider('provideClass')] public function shouldFormatClassString(string $string, string $expected): void { $filter = $this->extension->getFilters()[0]; @@ -29,7 +29,7 @@ public function shouldFormatClassString(string $string, string $expected): void $this->assertSame($expected, $result); } - public function provideClass(): array + public static function provideClass(): array { return [ // input, expected diff --git a/tests/Service/ErrorProfilerFormatterTest.php b/tests/Service/ErrorProfilerFormatterTest.php index 4447d6f..2cbc51c 100644 --- a/tests/Service/ErrorProfilerFormatterTest.php +++ b/tests/Service/ErrorProfilerFormatterTest.php @@ -5,6 +5,8 @@ use Lmc\Cqrs\Bundle\AbstractTestCase; use Lmc\Cqrs\Types\ValueObject\FormattedValue; use Lmc\Cqrs\Types\ValueObject\ProfilerItem; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\ErrorHandler\Exception\FlattenException; class ErrorProfilerFormatterTest extends AbstractTestCase @@ -16,11 +18,8 @@ protected function setUp(): void $this->formatter = new ErrorProfilerFormatter(); } - /** - * @dataProvider provideError - * - * @test - */ + #[Test] + #[DataProvider('provideError')] public function shouldFormatErrors(ProfilerItem $item, ProfilerItem $expected): void { $formatted = $this->formatter->formatItem($item); @@ -28,7 +27,7 @@ public function shouldFormatErrors(ProfilerItem $item, ProfilerItem $expected): $this->assertEquals($expected, $formatted); } - public function provideError(): array + public static function provideError(): array { return [ 'without any error' => [