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
Chromec Petr authored and MortalFlesh committed Mar 6, 2024
1 parent ab682ec commit 01cbd9a
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 92 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

## 3.1.0 - 2024-01-30
- Allow `psr/cache` v2
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"license": "MIT",
"type": "library",
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-hash": "*",
"ext-json": "*",
"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",
Expand All @@ -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": {
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>
13 changes: 4 additions & 9 deletions tests/Decoder/CallbackResponseDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -20,9 +19,7 @@ public function shouldSupportsResponseByGivenCallback(): void
$this->assertFalse($decoder->supports(42, null));
}

/**
* @test
*/
#[Test]
public function shouldSupportsInitiatorByGivenCallback(): void
{
$decoder = new CallbackResponseDecoder(
Expand All @@ -34,9 +31,7 @@ public function shouldSupportsInitiatorByGivenCallback(): void
$this->assertFalse($decoder->supports('response', null));
}

/**
* @test
*/
#[Test]
public function shouldDecodeByGivenCallback(): void
{
$decoder = new CallbackResponseDecoder(
Expand Down
11 changes: 5 additions & 6 deletions tests/Decoder/JsonResponseDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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],
Expand Down
11 changes: 5 additions & 6 deletions tests/Formatter/JsonProfilerFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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' => [
Expand Down
9 changes: 4 additions & 5 deletions tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,9 +20,7 @@ protected function setUp(): void
$this->dummyQueryHandler = new DummyQueryHandler();
}

/**
* @test
*/
#[Test]
public function shouldPrepareQueryByReturningItback(): void
{
$data = 'dummy-data';
Expand All @@ -30,7 +29,7 @@ public function shouldPrepareQueryByReturningItback(): void
$this->assertSame($query, $this->dummyQueryHandler->prepare($query));
}

/** @test */
#[Test]
public function shouldHandleDummyQueryDirectly(): void
{
$data = 'dummy-data';
Expand All @@ -45,7 +44,7 @@ public function shouldHandleDummyQueryDirectly(): void
);
}

/** @test */
#[Test]
public function shouldNotSupportOtherThanDummyQuery(): void
{
$notADummyQuery = new class() implements QueryInterface {
Expand Down
9 changes: 4 additions & 5 deletions tests/SendCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,9 +20,7 @@ protected function setUp(): void
$this->dummySendCommandHandler = new DummySendCommandHandler();
}

/**
* @test
*/
#[Test]
public function shouldPrepareCommandByReturningItback(): void
{
$data = 'dummy-data';
Expand All @@ -30,7 +29,7 @@ public function shouldPrepareCommandByReturningItback(): void
$this->assertSame($command, $this->dummySendCommandHandler->prepare($command));
}

/** @test */
#[Test]
public function shouldSendDummyCommandDirectly(): void
{
$data = 'dummy-data';
Expand All @@ -45,7 +44,7 @@ public function shouldSendDummyCommandDirectly(): void
);
}

/** @test */
#[Test]
public function shouldNotSupportOtherThanDummyCommand(): void
{
$notADummyCommand = new class() implements CommandInterface {
Expand Down
10 changes: 5 additions & 5 deletions tests/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
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);

$this->assertSame($expected, $type);
}

public function provideValues(): array
public static function provideValues(): array
{
return [
// value, expectedType
Expand Down
13 changes: 4 additions & 9 deletions tests/ValueObject/CacheKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand All @@ -32,9 +29,7 @@ public function shouldNotHashCacheKey(): void
$this->assertSame('key', (string) $key);
}

/**
* @test
*/
#[Test]
public function shouldHashCacheKeyByCustomAlgorithm(): void
{
$key = new CacheKey('key', 'md5');
Expand Down
10 changes: 5 additions & 5 deletions tests/ValueObject/CacheTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

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();

$this->assertSame($expectedSeconds, $cacheTime->getSeconds());
}

public function provideCacheTime(): array
public static function provideCacheTime(): array
{
return [
'no-cache' => [fn () => CacheTime::noCache(), 0],
Expand Down
11 changes: 5 additions & 6 deletions tests/ValueObject/FormattedValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@

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);

$this->assertSame($expected, (string) $formattedValue);
}

public function provideValues(): array
public static function provideValues(): array
{
return [
'formatted value is string' => ['original', 'formatted:value', 'formatted:value'],
Expand Down
Loading

0 comments on commit 01cbd9a

Please sign in to comment.