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 f068722..696effb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@
## Unreleased
+- Drop support for php 8.1
+- Update dependencies
## 2.1.0 - 2024-01-30
- Allow `psr/cache` v2
diff --git a/composer.json b/composer.json
index 90b3f79..6a8c3ea 100644
--- a/composer.json
+++ b/composer.json
@@ -4,15 +4,15 @@
"license": "MIT",
"type": "library",
"require": {
- "php": "^8.1",
+ "php": "^8.2",
"ext-json": "*",
"ext-mbstring": "*",
"lmc/cqrs-types": "^3.0",
"psr/cache": "^2.0 || ^3.0",
- "psr/http-message": "^1.0.1",
- "ramsey/collection": "^1.2.2",
+ "psr/http-message": "^1.0.1 || ^2.0",
+ "ramsey/collection": "^1.2.2 || ^2.0",
"ramsey/uuid": "^4.2.3",
- "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0"
+ "symfony/stopwatch": "^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.5",
@@ -21,8 +21,8 @@
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1.0",
- "phpunit/phpunit": "^9.5.20",
- "symfony/cache": "^5.2 || ^6.0"
+ "phpunit/phpunit": "^11.0.4",
+ "symfony/cache": "^5.2 || ^6.0 || ^7.0"
},
"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/
-
+
diff --git a/tests/CommandSenderTest.php b/tests/CommandSenderTest.php
index b1b16ec..a1e0d77 100644
--- a/tests/CommandSenderTest.php
+++ b/tests/CommandSenderTest.php
@@ -18,6 +18,8 @@
use Lmc\Cqrs\Types\ValueObject\OnSuccessInterface;
use Lmc\Cqrs\Types\ValueObject\PrioritizedItem;
use Lmc\Cqrs\Types\ValueObject\ProfilerItem;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Test;
class CommandSenderTest extends AbstractTestCase
{
@@ -36,9 +38,7 @@ protected function setUp(): void
$this->commandSenderWithoutFeatures = new CommandSender(null);
}
- /**
- * @test
- */
+ #[Test]
public function shouldSendCommand(): void
{
$this->commandSender->addHandler(new DummySendCommandHandler(), PrioritizedItem::PRIORITY_MEDIUM);
@@ -52,9 +52,7 @@ public function shouldSendCommand(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldProfileGivenCommand(): void
{
$profilerId = 'some-profiler-id';
@@ -88,9 +86,7 @@ public function shouldProfileGivenCommand(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotProfileNotProfileableCommand(): void
{
$dummyCommand = new DummyCommand('fresh-data');
@@ -104,9 +100,7 @@ public function shouldNotProfileNotProfileableCommand(): void
$this->assertCount(0, $this->profilerBag);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotProfileWithoutProfilerBag(): void
{
$profilerId = 'some-profiler-id';
@@ -121,9 +115,7 @@ public function shouldNotProfileWithoutProfilerBag(): void
$this->assertCount(0, $this->profilerBag);
}
- /**
- * @test
- */
+ #[Test]
public function shouldSendCommandAndDecodeResponse(): void
{
$this->commandSender->addHandler(new DummySendCommandHandler(), PrioritizedItem::PRIORITY_MEDIUM);
@@ -140,9 +132,7 @@ public function shouldSendCommandAndDecodeResponse(): void
$this->assertSame('decoded:fresh-data', $decodedResponse);
}
- /**
- * @test
- */
+ #[Test]
public function shouldProfileOriginalResponse(): void
{
$profilerId = 'some-profiler-id';
@@ -170,9 +160,7 @@ public function shouldProfileOriginalResponse(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldSendCommandDecodeResponseAndProfileIt(): void
{
$profilerId = 'some-profiler-id';
@@ -204,9 +192,7 @@ public function shouldSendCommandDecodeResponseAndProfileIt(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldThrowExceptionOnSendAndDecodeWithoutAnyHandler(): void
{
$command = new DummyCommand('fresh-data');
@@ -216,9 +202,7 @@ public function shouldThrowExceptionOnSendAndDecodeWithoutAnyHandler(): void
$this->commandSender->sendAndReturn($command);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotUseMoreThanOneHandler(): void
{
$command = new DummyCommand('fresh-data');
@@ -251,9 +235,7 @@ public function handle(
$this->assertSame('fresh-data', $response);
}
- /**
- * @test
- */
+ #[Test]
public function shouldSendCommandAndUseMultipleDecoders(): void
{
$profilerId = 'profiler-id';
@@ -302,9 +284,7 @@ public function shouldSendCommandAndUseMultipleDecoders(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldSendCommandAndUseOnlyOneDecoder(): void
{
$profilerId = 'profiler-id';
@@ -355,9 +335,7 @@ public function shouldSendCommandAndUseOnlyOneDecoder(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldSendConsequentCommand(): void
{
$commandA = new ProfileableCommandAdapter(new DummyCommand('response-A'), 'command-A');
@@ -387,10 +365,8 @@ public function shouldSendConsequentCommand(): void
}
}
- /**
- * @test
- * @dataProvider provideVerbosity
- */
+ #[Test]
+ #[DataProvider('provideVerbosity')]
public function shouldUseProfilerBagVerbosity(
string $verbosity,
bool $withDecoder,
@@ -440,7 +416,7 @@ public function shouldUseProfilerBagVerbosity(
}
}
- public function provideVerbosity(): array
+ public static function provideVerbosity(): array
{
return [
// verbosity, withDecoder, expected
diff --git a/tests/Handler/CallbackQueryHandlerTest.php b/tests/Handler/CallbackQueryHandlerTest.php
index acaf740..8405e5d 100644
--- a/tests/Handler/CallbackQueryHandlerTest.php
+++ b/tests/Handler/CallbackQueryHandlerTest.php
@@ -10,6 +10,8 @@
use Lmc\Cqrs\Types\ValueObject\CacheTime;
use Lmc\Cqrs\Types\ValueObject\OnErrorCallback;
use Lmc\Cqrs\Types\ValueObject\OnSuccessCallback;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Test;
class CallbackQueryHandlerTest extends AbstractTestCase
{
@@ -23,10 +25,9 @@ protected function setUp(): void
/**
* @param QueryInterface $query
- *
- * @dataProvider provideCallableQuery
- * @test
*/
+ #[Test]
+ #[DataProvider('provideCallableQuery')]
public function shouldSupportCallableQuery(QueryInterface $query): void
{
$this->assertTrue($this->handler->supports($query));
@@ -34,10 +35,9 @@ public function shouldSupportCallableQuery(QueryInterface $query): void
/**
* @param QueryInterface $query
- *
- * @dataProvider provideCallableQuery
- * @test
*/
+ #[Test]
+ #[DataProvider('provideCallableQuery')]
public function shouldHandleCallableQuery(QueryInterface $query, mixed $expectedResult): void
{
$this->handler->handle(
@@ -47,7 +47,7 @@ public function shouldHandleCallableQuery(QueryInterface $query, mixed $expected
);
}
- public function provideCallableQuery(): array
+ public static function provideCallableQuery(): array
{
return [
// query, expectedResult
diff --git a/tests/Handler/CallbackSendCommandHandlerTest.php b/tests/Handler/CallbackSendCommandHandlerTest.php
index e214064..482f1b4 100644
--- a/tests/Handler/CallbackSendCommandHandlerTest.php
+++ b/tests/Handler/CallbackSendCommandHandlerTest.php
@@ -7,6 +7,8 @@
use Lmc\Cqrs\Types\CommandInterface;
use Lmc\Cqrs\Types\ValueObject\OnErrorCallback;
use Lmc\Cqrs\Types\ValueObject\OnSuccessCallback;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Test;
class CallbackSendCommandHandlerTest extends AbstractTestCase
{
@@ -20,10 +22,9 @@ protected function setUp(): void
/**
* @param CommandInterface $command
- *
- * @dataProvider provideCallableCommand
- * @test
*/
+ #[Test]
+ #[DataProvider('provideCallableCommand')]
public function shouldSupportCallableCommand(CommandInterface $command): void
{
$this->assertTrue($this->handler->supports($command));
@@ -31,10 +32,9 @@ public function shouldSupportCallableCommand(CommandInterface $command): void
/**
* @param CommandInterface $command
- *
- * @dataProvider provideCallableCommand
- * @test
*/
+ #[Test]
+ #[DataProvider('provideCallableCommand')]
public function shouldHandleCallableCommand(CommandInterface $command, mixed $expectedResult): void
{
$this->handler->handle(
@@ -44,7 +44,7 @@ public function shouldHandleCallableCommand(CommandInterface $command, mixed $ex
);
}
- public function provideCallableCommand(): array
+ public static function provideCallableCommand(): array
{
return [
// command, expectedResult
diff --git a/tests/QueryFetcherTest.php b/tests/QueryFetcherTest.php
index 3df54a7..edba439 100644
--- a/tests/QueryFetcherTest.php
+++ b/tests/QueryFetcherTest.php
@@ -24,6 +24,8 @@
use Lmc\Cqrs\Types\ValueObject\OnSuccessInterface;
use Lmc\Cqrs\Types\ValueObject\PrioritizedItem;
use Lmc\Cqrs\Types\ValueObject\ProfilerItem;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Test;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -46,18 +48,14 @@ protected function setUp(): void
$this->queryFetcherWithoutFeatures = new QueryFetcher(false, null, null);
}
- /**
- * @test
- */
+ #[Test]
public function shouldHaveDefaultHandlers(): void
{
$this->assertNotEmpty($this->queryFetcher->getHandlers());
$this->assertEmpty($this->queryFetcherWithoutFeatures->getHandlers());
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotFetchNotCacheableQueryFromCache(): void
{
$key = new CacheKey('some-key');
@@ -79,9 +77,7 @@ public function shouldNotFetchNotCacheableQueryFromCache(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchQueryDataFromCache(): void
{
$key = new CacheKey('some-key');
@@ -98,9 +94,7 @@ public function shouldFetchQueryDataFromCache(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchQueryDataByHandler(): void
{
$this->queryFetcher->addHandler(new DummyQueryHandler(), PrioritizedItem::PRIORITY_LOWEST);
@@ -114,9 +108,7 @@ public function shouldFetchQueryDataByHandler(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchQueryDataFromCacheAndNotByHandler(): void
{
$key = new CacheKey('some-key');
@@ -135,9 +127,7 @@ public function shouldFetchQueryDataFromCacheAndNotByHandler(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchQueryDataFromHandlerWithHigherPriorityAndCacheThem(): void
{
$key = new CacheKey('some-key');
@@ -160,9 +150,7 @@ public function shouldFetchQueryDataFromHandlerWithHigherPriorityAndCacheThem():
$this->assertSame('fresh-data', $item->get());
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchFreshQueryDataAndCacheThem(): void
{
$key = new CacheKey('some-key');
@@ -185,9 +173,7 @@ public function shouldFetchFreshQueryDataAndCacheThem(): void
$this->assertSame('fresh-data', $item->get());
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotFetchQueryDataWithNoCacheGiven(): void
{
$key = new CacheKey('some-key');
@@ -207,9 +193,7 @@ public function shouldNotFetchQueryDataWithNoCacheGiven(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotFetchQueryDataWithNoItemInCache(): void
{
$key = new CacheKey('some-key');
@@ -227,9 +211,7 @@ public function shouldNotFetchQueryDataWithNoItemInCache(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotFetchExpiredData(): void
{
$key = new CacheKey('some-key');
@@ -251,9 +233,7 @@ public function shouldNotFetchExpiredData(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotFetchCachedDataFromCacheWithNoCacheTime(): void
{
$key = new CacheKey('some-key');
@@ -275,9 +255,7 @@ public function shouldNotFetchCachedDataFromCacheWithNoCacheTime(): void
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotFetchCachedDataFromCacheWithDisabledCacheAndDontChangeThemInCache(): void
{
$key = new CacheKey('some-key');
@@ -314,9 +292,7 @@ public function shouldNotFetchCachedDataFromCacheWithDisabledCacheAndDontChangeT
);
}
- /**
- * @test
- */
+ #[Test]
public function shouldInvalidateCachedItemByQuery(): void
{
$profilerId = 'profiler-id';
@@ -364,9 +340,7 @@ public function shouldInvalidateCachedItemByQuery(): void
$this->assertCount(3, $this->profilerBag);
}
- /**
- * @test
- */
+ #[Test]
public function shouldInvalidateCachedItemByHashedKey(): void
{
$profilerId = 'profiler-id';
@@ -425,9 +399,7 @@ protected function prepareCachedData(CacheKey $key, string $value, \DateTime $ex
$this->cache->save($item);
}
- /**
- * @test
- */
+ #[Test]
public function shouldProfileGivenQuery(): void
{
$profilerId = 'some-profiler-key';
@@ -457,9 +429,7 @@ public function shouldProfileGivenQuery(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldProfileGivenCacheableQuery(): void
{
$profilerId = 'some-profiler-key';
@@ -498,9 +468,7 @@ public function shouldProfileGivenCacheableQuery(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldProfileGivenCacheableQueryFetchedFromCache(): void
{
$profilerId = 'some-profiler-key';
@@ -542,9 +510,7 @@ public function shouldProfileGivenCacheableQueryFetchedFromCache(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotProfileNotProfileableQuery(): void
{
$dummyQuery = new DummyQuery('fresh-data');
@@ -558,9 +524,7 @@ public function shouldNotProfileNotProfileableQuery(): void
$this->assertCount(0, $this->profilerBag);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotProfileWithoutProfilerBag(): void
{
$profilerId = 'some-profiler-key';
@@ -575,9 +539,7 @@ public function shouldNotProfileWithoutProfilerBag(): void
$this->assertCount(0, $this->profilerBag);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchAndDecodeQuery(): void
{
$this->queryFetcher->addHandler(new DummyQueryHandler(), PrioritizedItem::PRIORITY_MEDIUM);
@@ -595,9 +557,7 @@ public function shouldFetchAndDecodeQuery(): void
$this->assertSame('decoded:fresh-data', $decodedResponse);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchAndDecodeQueryAndProfileOriginalResponse(): void
{
$profilerId = 'profiler-id';
@@ -624,9 +584,7 @@ public function shouldFetchAndDecodeQueryAndProfileOriginalResponse(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchFromCacheAndDecodeQueryAndProfileIt(): void
{
$profilerId = 'profiler-id';
@@ -674,9 +632,7 @@ public function shouldFetchFromCacheAndDecodeQueryAndProfileIt(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchFreshQuery(): void
{
$key = new CacheKey('some-key');
@@ -693,9 +649,7 @@ public function shouldFetchFreshQuery(): void
$this->assertSame('cached-value', $decodedResponse);
}
- /**
- * @test
- */
+ #[Test]
public function shouldThrowExceptionOnFetchAndDecodeWithoutAnyHandler(): void
{
$query = new DummyQuery('fresh-data');
@@ -705,9 +659,7 @@ public function shouldThrowExceptionOnFetchAndDecodeWithoutAnyHandler(): void
$this->queryFetcher->fetchAndReturn($query);
}
- /**
- * @test
- */
+ #[Test]
public function shouldNotUseMoreThanOneHandler(): void
{
$query = new DummyQuery('fresh-data');
@@ -740,9 +692,7 @@ public function handle(
$this->assertSame('fresh-data', $response);
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchQueryAndUseMultipleDecodersAndCacheTheFinalResult(): void
{
$profilerId = 'profiler-id';
@@ -797,9 +747,7 @@ public function shouldFetchQueryAndUseMultipleDecodersAndCacheTheFinalResult():
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchQueryAndUseOnlyOneDecoder(): void
{
$profilerId = 'profiler-id';
@@ -856,9 +804,7 @@ public function shouldFetchQueryAndUseOnlyOneDecoder(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldFetchConsequentQuery(): void
{
$queryA = new ProfileableQueryAdapter(new DummyQuery('response-A'), 'query-A');
@@ -888,9 +834,7 @@ public function shouldFetchConsequentQuery(): void
}
}
- /**
- * @test
- */
+ #[Test]
public function shouldCacheResponseBeforeDecodingByImpureDecoder(): void
{
$onError = new OnErrorCallback(fn (\Throwable $error) => $this->fail($error->getMessage()));
@@ -931,10 +875,8 @@ public function shouldCacheResponseBeforeDecodingByImpureDecoder(): void
$this->assertSame('fresh-data', $item->get());
}
- /**
- * @test
- * @dataProvider provideVerbosity
- */
+ #[Test]
+ #[DataProvider('provideVerbosity')]
public function shouldUseProfilerBagVerbosity(
string $verbosity,
bool $withDecoder,
@@ -988,7 +930,7 @@ public function shouldUseProfilerBagVerbosity(
}
}
- public function provideVerbosity(): array
+ public static function provideVerbosity(): array
{
return [
// verbosity, withDecoder, expected