diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4317b80..bca9a04 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - php-version: ['8.1'] + php-version: ['8.1', '8.2', '8.3'] dependencies: [''] include: - { php-version: '8.1', dependencies: '--prefer-lowest --prefer-stable' } diff --git a/CHANGELOG.md b/CHANGELOG.md index f40cb82..41dec00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased +- Update dependencies ## 3.1.0 - 2024-01-30 - Allow `psr/cache` v2 diff --git a/composer.json b/composer.json index 9ce3666..b29c410 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "ext-mbstring": "*", "psr/cache": "^2.0 || ^3.0", "psr/http-client": "^1.0", - "psr/http-message": "^1.0" + "psr/http-message": "^1.0 || ^2.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.5", @@ -19,7 +19,7 @@ "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.4", "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^11.0.4" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a0aed18..beb0fc5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,34 +1,29 @@ - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" colors="true" + bootstrap="vendor/autoload.php"> - - src - - - tests/ - + + + src + + diff --git a/tests/Decoder/CallbackResponseDecoderTest.php b/tests/Decoder/CallbackResponseDecoderTest.php index 263ba4c..2748c5e 100644 --- a/tests/Decoder/CallbackResponseDecoderTest.php +++ b/tests/Decoder/CallbackResponseDecoderTest.php @@ -2,13 +2,12 @@ namespace Lmc\Cqrs\Types\Decoder; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class CallbackResponseDecoderTest extends TestCase { - /** - * @test - */ + #[Test] public function shouldSupportsResponseByGivenCallback(): void { $decoder = new CallbackResponseDecoder( @@ -20,9 +19,7 @@ public function shouldSupportsResponseByGivenCallback(): void $this->assertFalse($decoder->supports(42, null)); } - /** - * @test - */ + #[Test] public function shouldSupportsInitiatorByGivenCallback(): void { $decoder = new CallbackResponseDecoder( @@ -34,9 +31,7 @@ public function shouldSupportsInitiatorByGivenCallback(): void $this->assertFalse($decoder->supports('response', null)); } - /** - * @test - */ + #[Test] public function shouldDecodeByGivenCallback(): void { $decoder = new CallbackResponseDecoder( diff --git a/tests/Decoder/JsonResponseDecoderTest.php b/tests/Decoder/JsonResponseDecoderTest.php index a68351e..25fa206 100644 --- a/tests/Decoder/JsonResponseDecoderTest.php +++ b/tests/Decoder/JsonResponseDecoderTest.php @@ -2,15 +2,14 @@ namespace Lmc\Cqrs\Types\Decoder; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class JsonResponseDecoderTest extends TestCase { - /** - * @dataProvider provideStringInput - * - * @test - */ + #[Test] + #[DataProvider('provideStringInput')] public function shouldDecodeGivenString(?string $input, bool $supports, string|array|null $expected): void { $decoder = new JsonResponseDecoder(); @@ -19,7 +18,7 @@ public function shouldDecodeGivenString(?string $input, bool $supports, string|a $this->assertSame($expected, $decoder->decode($input)); } - public function provideStringInput(): array + public static function provideStringInput(): array { return [ 'null' => [null, false, null], diff --git a/tests/Formatter/JsonProfilerFormatterTest.php b/tests/Formatter/JsonProfilerFormatterTest.php index 081e149..6a8d4db 100644 --- a/tests/Formatter/JsonProfilerFormatterTest.php +++ b/tests/Formatter/JsonProfilerFormatterTest.php @@ -4,15 +4,14 @@ use Lmc\Cqrs\Types\ValueObject\FormattedValue; use Lmc\Cqrs\Types\ValueObject\ProfilerItem; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class JsonProfilerFormatterTest extends TestCase { - /** - * @dataProvider provideProfilerItem - * - * @test - */ + #[Test] + #[DataProvider('provideProfilerItem')] public function shouldFormatProfilerItem(ProfilerItem $item, ProfilerItem $expected): void { $formatter = new JsonProfilerFormatter(); @@ -22,7 +21,7 @@ public function shouldFormatProfilerItem(ProfilerItem $item, ProfilerItem $expec $this->assertEquals($expected, $formatted); } - public function provideProfilerItem(): array + public static function provideProfilerItem(): array { return [ 'without any json' => [ diff --git a/tests/QueryTest.php b/tests/QueryTest.php index a129e9c..816adb6 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -8,6 +8,7 @@ use Lmc\Cqrs\Types\Fixture\DummyQueryHandler; use Lmc\Cqrs\Types\ValueObject\OnErrorCallback; use Lmc\Cqrs\Types\ValueObject\OnSuccessCallback; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class QueryTest extends TestCase @@ -19,9 +20,7 @@ protected function setUp(): void $this->dummyQueryHandler = new DummyQueryHandler(); } - /** - * @test - */ + #[Test] public function shouldPrepareQueryByReturningItback(): void { $data = 'dummy-data'; @@ -30,7 +29,7 @@ public function shouldPrepareQueryByReturningItback(): void $this->assertSame($query, $this->dummyQueryHandler->prepare($query)); } - /** @test */ + #[Test] public function shouldHandleDummyQueryDirectly(): void { $data = 'dummy-data'; @@ -45,7 +44,7 @@ public function shouldHandleDummyQueryDirectly(): void ); } - /** @test */ + #[Test] public function shouldNotSupportOtherThanDummyQuery(): void { $notADummyQuery = new class() implements QueryInterface { diff --git a/tests/SendCommandTest.php b/tests/SendCommandTest.php index e24bf4e..765402c 100644 --- a/tests/SendCommandTest.php +++ b/tests/SendCommandTest.php @@ -8,6 +8,7 @@ use Lmc\Cqrs\Types\Fixture\DummySendCommandHandler; use Lmc\Cqrs\Types\ValueObject\OnErrorCallback; use Lmc\Cqrs\Types\ValueObject\OnSuccessCallback; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class SendCommandTest extends TestCase @@ -19,9 +20,7 @@ protected function setUp(): void $this->dummySendCommandHandler = new DummySendCommandHandler(); } - /** - * @test - */ + #[Test] public function shouldPrepareCommandByReturningItback(): void { $data = 'dummy-data'; @@ -30,7 +29,7 @@ public function shouldPrepareCommandByReturningItback(): void $this->assertSame($command, $this->dummySendCommandHandler->prepare($command)); } - /** @test */ + #[Test] public function shouldSendDummyCommandDirectly(): void { $data = 'dummy-data'; @@ -45,7 +44,7 @@ public function shouldSendDummyCommandDirectly(): void ); } - /** @test */ + #[Test] public function shouldNotSupportOtherThanDummyCommand(): void { $notADummyCommand = new class() implements CommandInterface { diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 2735cb3..9b1e8ed 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -6,14 +6,14 @@ use Lmc\Cqrs\Types\Fixture\DecodedSelf; use Lmc\Cqrs\Types\Fixture\DummyData; use Lmc\Cqrs\Types\ValueObject\DecodedValue; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class UtilsTest extends TestCase { - /** - * @test - * @dataProvider provideValues - */ + #[Test] + #[DataProvider('provideValues')] public function shouldGetTypeOfGivenValue(mixed $value, string $expected): void { $type = Utils::getType($value); @@ -21,7 +21,7 @@ public function shouldGetTypeOfGivenValue(mixed $value, string $expected): void $this->assertSame($expected, $type); } - public function provideValues(): array + public static function provideValues(): array { return [ // value, expectedType diff --git a/tests/ValueObject/CacheKeyTest.php b/tests/ValueObject/CacheKeyTest.php index 2174e55..db56cd9 100644 --- a/tests/ValueObject/CacheKeyTest.php +++ b/tests/ValueObject/CacheKeyTest.php @@ -2,13 +2,12 @@ namespace Lmc\Cqrs\Types\ValueObject; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class CacheKeyTest extends TestCase { - /** - * @test - */ + #[Test] public function shouldHashCacheKeyWithDefaultAlgorithm(): void { $key = new CacheKey('key'); @@ -19,9 +18,7 @@ public function shouldHashCacheKeyWithDefaultAlgorithm(): void $this->assertSame(hash('sha256', 'key'), (string) $key); } - /** - * @test - */ + #[Test] public function shouldNotHashCacheKey(): void { $key = new CacheKey('key', CacheKey::DONT_HASH); @@ -32,9 +29,7 @@ public function shouldNotHashCacheKey(): void $this->assertSame('key', (string) $key); } - /** - * @test - */ + #[Test] public function shouldHashCacheKeyByCustomAlgorithm(): void { $key = new CacheKey('key', 'md5'); diff --git a/tests/ValueObject/CacheTimeTest.php b/tests/ValueObject/CacheTimeTest.php index 0e931ad..7cb99eb 100644 --- a/tests/ValueObject/CacheTimeTest.php +++ b/tests/ValueObject/CacheTimeTest.php @@ -2,14 +2,14 @@ namespace Lmc\Cqrs\Types\ValueObject; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class CacheTimeTest extends TestCase { - /** - * @test - * @dataProvider provideCacheTime - */ + #[Test] + #[DataProvider('provideCacheTime')] public function shouldCreateCacheTime(callable $createCacheTime, int $expectedSeconds): void { $cacheTime = $createCacheTime(); @@ -17,7 +17,7 @@ public function shouldCreateCacheTime(callable $createCacheTime, int $expectedSe $this->assertSame($expectedSeconds, $cacheTime->getSeconds()); } - public function provideCacheTime(): array + public static function provideCacheTime(): array { return [ 'no-cache' => [fn () => CacheTime::noCache(), 0], diff --git a/tests/ValueObject/FormattedValueTest.php b/tests/ValueObject/FormattedValueTest.php index 3ace555..b6b4ebf 100644 --- a/tests/ValueObject/FormattedValueTest.php +++ b/tests/ValueObject/FormattedValueTest.php @@ -2,15 +2,14 @@ namespace Lmc\Cqrs\Types\ValueObject; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class FormattedValueTest extends TestCase { - /** - * @dataProvider provideValues - * - * @test - */ + #[Test] + #[DataProvider('provideValues')] public function shouldCastFormattedValueToString(mixed $original, mixed $formatted, string $expected): void { $formattedValue = new FormattedValue($original, $formatted); @@ -18,7 +17,7 @@ public function shouldCastFormattedValueToString(mixed $original, mixed $formatt $this->assertSame($expected, (string) $formattedValue); } - public function provideValues(): array + public static function provideValues(): array { return [ 'formatted value is string' => ['original', 'formatted:value', 'formatted:value'], diff --git a/tests/ValueObject/OnErrorCallbackTest.php b/tests/ValueObject/OnErrorCallbackTest.php index ff3d2a7..86247ba 100644 --- a/tests/ValueObject/OnErrorCallbackTest.php +++ b/tests/ValueObject/OnErrorCallbackTest.php @@ -2,13 +2,12 @@ namespace Lmc\Cqrs\Types\ValueObject; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class OnErrorCallbackTest extends TestCase { - /** - * @test - */ + #[Test] public function shouldUseGivenCallback(): void { $actualError = null; @@ -22,9 +21,7 @@ public function shouldUseGivenCallback(): void $this->assertSame('Actual error', $actualError); } - /** - * @test - */ + #[Test] public function shouldThrowGivenError(): void { $callback = OnErrorCallback::throwOnError(); @@ -34,9 +31,7 @@ public function shouldThrowGivenError(): void $callback(new \Exception('Should be thrown.')); } - /** - * @test - */ + #[Test] public function shouldIgnoreError(): void { $callback = OnErrorCallback::ignoreError(); diff --git a/tests/ValueObject/PrioritizedItemTest.php b/tests/ValueObject/PrioritizedItemTest.php index 1d534be..ce1c385 100644 --- a/tests/ValueObject/PrioritizedItemTest.php +++ b/tests/ValueObject/PrioritizedItemTest.php @@ -2,13 +2,12 @@ namespace Lmc\Cqrs\Types\ValueObject; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class PrioritizedItemTest extends TestCase { - /** - * @test - */ + #[Test] public function shouldSortPrioritizedItemsByPriority(): void { $items = [ diff --git a/tests/ValueObject/ProfilerItemTest.php b/tests/ValueObject/ProfilerItemTest.php index 245659a..adb6493 100644 --- a/tests/ValueObject/ProfilerItemTest.php +++ b/tests/ValueObject/ProfilerItemTest.php @@ -2,13 +2,12 @@ namespace Lmc\Cqrs\Types\ValueObject; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class ProfilerItemTest extends TestCase { - /** - * @test - */ + #[Test] public function shouldProfileResponseAsItIsInThatMoment(): void { $response = new \stdClass(); @@ -21,9 +20,7 @@ public function shouldProfileResponseAsItIsInThatMoment(): void $this->assertSame('foo', $profilerItem->getResponse()->value); } - /** - * @test - */ + #[Test] public function shouldProfileResponseAsItIsInThatMomentViaSetter(): void { $response = new \stdClass();