Skip to content

Commit

Permalink
Drop support for php 8.1 and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Mar 6, 2024
1 parent 47f09b9 commit 122de4c
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 168 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<!-- There should always be "Unreleased" section at the beginning. -->

## Unreleased
- Drop support for php 8.1
- Update dependencies

## 2.1.0 - 2024-01-30
- Allow `psr/cache` v2
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
19 changes: 7 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>

xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" colors="true"
bootstrap="vendor/autoload.php">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="./reports/clover.xml"/>
<html outputDirectory="./reports" highLowerBound="90"/>
</report>
</coverage>

<php>
<!-- E_ALL = 30719 -->
<ini name="error_reporting" value="30719"/>
</php>

<testsuites>
<testsuite name="unit">
<directory>tests/</directory>
</testsuite>
</testsuites>

<logging>
<junit outputFile="./reports/junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
58 changes: 17 additions & 41 deletions tests/CommandSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
Expand All @@ -52,9 +52,7 @@ public function shouldSendCommand(): void
);
}

/**
* @test
*/
#[Test]
public function shouldProfileGivenCommand(): void
{
$profilerId = 'some-profiler-id';
Expand Down Expand Up @@ -88,9 +86,7 @@ public function shouldProfileGivenCommand(): void
}
}

/**
* @test
*/
#[Test]
public function shouldNotProfileNotProfileableCommand(): void
{
$dummyCommand = new DummyCommand('fresh-data');
Expand All @@ -104,9 +100,7 @@ public function shouldNotProfileNotProfileableCommand(): void
$this->assertCount(0, $this->profilerBag);
}

/**
* @test
*/
#[Test]
public function shouldNotProfileWithoutProfilerBag(): void
{
$profilerId = 'some-profiler-id';
Expand All @@ -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);
Expand All @@ -140,9 +132,7 @@ public function shouldSendCommandAndDecodeResponse(): void
$this->assertSame('decoded:fresh-data', $decodedResponse);
}

/**
* @test
*/
#[Test]
public function shouldProfileOriginalResponse(): void
{
$profilerId = 'some-profiler-id';
Expand Down Expand Up @@ -170,9 +160,7 @@ public function shouldProfileOriginalResponse(): void
}
}

/**
* @test
*/
#[Test]
public function shouldSendCommandDecodeResponseAndProfileIt(): void
{
$profilerId = 'some-profiler-id';
Expand Down Expand Up @@ -204,9 +192,7 @@ public function shouldSendCommandDecodeResponseAndProfileIt(): void
}
}

/**
* @test
*/
#[Test]
public function shouldThrowExceptionOnSendAndDecodeWithoutAnyHandler(): void
{
$command = new DummyCommand('fresh-data');
Expand All @@ -216,9 +202,7 @@ public function shouldThrowExceptionOnSendAndDecodeWithoutAnyHandler(): void
$this->commandSender->sendAndReturn($command);
}

/**
* @test
*/
#[Test]
public function shouldNotUseMoreThanOneHandler(): void
{
$command = new DummyCommand('fresh-data');
Expand Down Expand Up @@ -251,9 +235,7 @@ public function handle(
$this->assertSame('fresh-data', $response);
}

/**
* @test
*/
#[Test]
public function shouldSendCommandAndUseMultipleDecoders(): void
{
$profilerId = 'profiler-id';
Expand Down Expand Up @@ -302,9 +284,7 @@ public function shouldSendCommandAndUseMultipleDecoders(): void
}
}

/**
* @test
*/
#[Test]
public function shouldSendCommandAndUseOnlyOneDecoder(): void
{
$profilerId = 'profiler-id';
Expand Down Expand Up @@ -355,9 +335,7 @@ public function shouldSendCommandAndUseOnlyOneDecoder(): void
}
}

/**
* @test
*/
#[Test]
public function shouldSendConsequentCommand(): void
{
$commandA = new ProfileableCommandAdapter(new DummyCommand('response-A'), 'command-A');
Expand Down Expand Up @@ -387,10 +365,8 @@ public function shouldSendConsequentCommand(): void
}
}

/**
* @test
* @dataProvider provideVerbosity
*/
#[Test]
#[DataProvider('provideVerbosity')]
public function shouldUseProfilerBagVerbosity(
string $verbosity,
bool $withDecoder,
Expand Down Expand Up @@ -440,7 +416,7 @@ public function shouldUseProfilerBagVerbosity(
}
}

public function provideVerbosity(): array
public static function provideVerbosity(): array
{
return [
// verbosity, withDecoder, expected
Expand Down
14 changes: 7 additions & 7 deletions tests/Handler/CallbackQueryHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -23,21 +25,19 @@ protected function setUp(): void

/**
* @param QueryInterface<callable(): mixed> $query
*
* @dataProvider provideCallableQuery
* @test
*/
#[Test]
#[DataProvider('provideCallableQuery')]
public function shouldSupportCallableQuery(QueryInterface $query): void
{
$this->assertTrue($this->handler->supports($query));
}

/**
* @param QueryInterface<callable(): mixed> $query
*
* @dataProvider provideCallableQuery
* @test
*/
#[Test]
#[DataProvider('provideCallableQuery')]
public function shouldHandleCallableQuery(QueryInterface $query, mixed $expectedResult): void
{
$this->handler->handle(
Expand All @@ -47,7 +47,7 @@ public function shouldHandleCallableQuery(QueryInterface $query, mixed $expected
);
}

public function provideCallableQuery(): array
public static function provideCallableQuery(): array
{
return [
// query, expectedResult
Expand Down
14 changes: 7 additions & 7 deletions tests/Handler/CallbackSendCommandHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -20,21 +22,19 @@ protected function setUp(): void

/**
* @param CommandInterface<callable(): mixed> $command
*
* @dataProvider provideCallableCommand
* @test
*/
#[Test]
#[DataProvider('provideCallableCommand')]
public function shouldSupportCallableCommand(CommandInterface $command): void
{
$this->assertTrue($this->handler->supports($command));
}

/**
* @param CommandInterface<callable(): mixed> $command
*
* @dataProvider provideCallableCommand
* @test
*/
#[Test]
#[DataProvider('provideCallableCommand')]
public function shouldHandleCallableCommand(CommandInterface $command, mixed $expectedResult): void
{
$this->handler->handle(
Expand All @@ -44,7 +44,7 @@ public function shouldHandleCallableCommand(CommandInterface $command, mixed $ex
);
}

public function provideCallableCommand(): array
public static function provideCallableCommand(): array
{
return [
// command, expectedResult
Expand Down
Loading

0 comments on commit 122de4c

Please sign in to comment.