Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for php 8.1 and uUpdate dependencies #5

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.0.0 - 2022-04-27
- Require php 8.1
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"license": "MIT",
"type": "library",
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"ext-mbstring": "*",
"fig/http-message-util": "^1.1",
"lmc/cqrs-types": "^3.0",
"lmc/cqrs-types": "^3.2",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
"psr/http-message": "^1.0 || ^2.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.5",
Expand All @@ -22,7 +22,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 All @@ -36,9 +36,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
},
Expand Down
6 changes: 0 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@ parameters:
- tests/

reportUnmatchedIgnoredErrors: true

ignoreErrors:
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: src/Command/AbstractHttpPostCommand.php
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>
8 changes: 5 additions & 3 deletions tests/AbstractHttpTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Lmc\Cqrs\Http;

use Nyholm\Psr7\Uri;
use PHPUnit\Framework\Attributes\Before;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Client\ClientInterface;
Expand All @@ -17,13 +19,13 @@ abstract class AbstractHttpTestCase extends TestCase
/** @var RequestFactoryInterface|MockObject */
protected RequestFactoryInterface $requestFactory;

/** @before */
#[Before]
public function setUpClient(): void
{
$this->client = $this->createMock(ClientInterface::class);
}

/** @before */
#[Before]
public function setUpRequestFactory(): void
{
$this->requestFactory = $this->createMock(RequestFactoryInterface::class);
Expand All @@ -36,7 +38,7 @@ protected function prepareRequest(string $url, string $method): RequestInterface

$request->expects($this->any())
->method('getUri')
->willReturn($url);
->willReturn(new Uri($url));

$request->expects($this->any())
->method('getMethod')
Expand Down
18 changes: 9 additions & 9 deletions tests/Decoder/HttpMessageResponseDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use GuzzleHttp\Psr7\Utils;
use Lmc\Cqrs\Http\AbstractHttpTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;

class HttpMessageResponseDecoderTest extends AbstractHttpTestCase
{
Expand All @@ -14,10 +16,8 @@ protected function setUp(): void
$this->decoder = new HttpMessageResponseDecoder();
}

/**
* @dataProvider provideMessage
* @test
*/
#[Test]
#[DataProvider('provideMessage')]
public function shouldDecodeNyholmMessage(mixed $message, bool $isSupported, mixed $expected): void
{
$decoded = $this->decoder->decode($message);
Expand All @@ -26,19 +26,19 @@ public function shouldDecodeNyholmMessage(mixed $message, bool $isSupported, mix
$this->assertEquals($expected, $decoded);
}

public function provideMessage(): iterable
public static function provideMessage(): iterable
{
yield 'not a message' => [
$obj = new \stdClass(),
false,
$obj,
];

yield from $this->provideNyholmMessage();
yield from $this->provideGuzzleMessage();
yield from self::provideNyholmMessage();
yield from self::provideGuzzleMessage();
}

public function provideNyholmMessage(): iterable
public static function provideNyholmMessage(): iterable
{
yield 'request Nyholm with body' => [
(new \Nyholm\Psr7\Request('post', 'url'))->withBody($stream = \Nyholm\Psr7\Stream::create('body')),
Expand All @@ -59,7 +59,7 @@ public function provideNyholmMessage(): iterable
];
}

public function provideGuzzleMessage(): iterable
public static function provideGuzzleMessage(): iterable
{
yield 'Guzzle request with body' => [
(new \GuzzleHttp\Psr7\Request('post', 'url'))->withBody($stream = Utils::streamFor('body')),
Expand Down
18 changes: 9 additions & 9 deletions tests/Decoder/StreamResponseDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use GuzzleHttp\Psr7\Utils;
use Lmc\Cqrs\Http\AbstractHttpTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;

class StreamResponseDecoderTest extends AbstractHttpTestCase
{
Expand All @@ -14,10 +16,8 @@ protected function setUp(): void
$this->decoder = new StreamResponseDecoder();
}

/**
* @dataProvider provideMessage
* @test
*/
#[Test]
#[DataProvider('provideMessage')]
public function shouldDecodeNyholmMessage(mixed $message, bool $isSupported, mixed $expected): void
{
$decoded = $this->decoder->decode($message);
Expand All @@ -26,19 +26,19 @@ public function shouldDecodeNyholmMessage(mixed $message, bool $isSupported, mix
$this->assertEquals($expected, $decoded);
}

public function provideMessage(): iterable
public static function provideMessage(): iterable
{
yield 'not a stream' => [
$obj = new \stdClass(),
false,
$obj,
];

yield from $this->provideNyholmMessage();
yield from $this->provideGuzzleMessage();
yield from self::provideNyholmMessage();
yield from self::provideGuzzleMessage();
}

public function provideNyholmMessage(): iterable
public static function provideNyholmMessage(): iterable
{
yield 'Nyholm stream' => [
\Nyholm\Psr7\Stream::create('body'),
Expand All @@ -47,7 +47,7 @@ public function provideNyholmMessage(): iterable
];
}

public function provideGuzzleMessage(): iterable
public static function provideGuzzleMessage(): iterable
{
yield 'Guzzle stream' => [
Utils::streamFor('body'),
Expand Down
27 changes: 13 additions & 14 deletions tests/Formatter/HttpProfilerFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Lmc\Cqrs\Http\AbstractHttpTestCase;
use Lmc\Cqrs\Types\ValueObject\FormattedValue;
use Lmc\Cqrs\Types\ValueObject\ProfilerItem;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;

class HttpProfilerFormatterTest extends AbstractHttpTestCase
{
Expand All @@ -16,33 +18,30 @@ protected function setUp(): void
$this->formatter = new HttpProfilerFormatter();
}

/**
* @dataProvider provideProfilerItem
*
* @test
*/
#[Test]
#[DataProvider('provideProfilerItem')]
public function shouldProfileItem(ProfilerItem $item, ProfilerItem $expected): void
{
$formatted = $this->formatter->formatItem($item);

$this->assertEquals($expected, $formatted);
}

public function provideProfilerItem(): iterable
public static function provideProfilerItem(): iterable
{
yield 'without anything to format' => [
new ProfilerItem('id', null, 'test'),
new ProfilerItem('id', null, 'test'),
];

yield from $this->provideNyholmItems();
yield from $this->provideNyholmAdditioanlItems();
yield from self::provideNyholmItems();
yield from self::provideNyholmAdditioanlItems();

yield from $this->provideGuzzleItems();
yield from $this->provideGuzzleAdditionalItems();
yield from self::provideGuzzleItems();
yield from self::provideGuzzleAdditionalItems();
}

public function provideNyholmItems(): iterable
public static function provideNyholmItems(): iterable
{
yield 'with Nyholm request with body' => [
new ProfilerItem(
Expand Down Expand Up @@ -132,7 +131,7 @@ public function provideNyholmItems(): iterable
];
}

public function provideNyholmAdditioanlItems(): iterable
public static function provideNyholmAdditioanlItems(): iterable
{
yield 'with additional Nyholm request with body' => [
new ProfilerItem(
Expand Down Expand Up @@ -225,7 +224,7 @@ public function provideNyholmAdditioanlItems(): iterable
];
}

public function provideGuzzleItems(): iterable
public static function provideGuzzleItems(): iterable
{
yield 'with Guzzle request with body' => [
new ProfilerItem(
Expand Down Expand Up @@ -315,7 +314,7 @@ public function provideGuzzleItems(): iterable
];
}

public function provideGuzzleAdditionalItems(): iterable
public static function provideGuzzleAdditionalItems(): iterable
{
yield 'with additional Guzzle request with body' => [
new ProfilerItem(
Expand Down
13 changes: 4 additions & 9 deletions tests/Handler/HttpQueryHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Lmc\Cqrs\Types\Exception\CqrsExceptionInterface;
use Lmc\Cqrs\Types\ValueObject\OnErrorCallback;
use Lmc\Cqrs\Types\ValueObject\OnSuccessCallback;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Message\ResponseInterface;

class HttpQueryHandlerTest extends AbstractHttpTestCase
Expand All @@ -20,9 +21,7 @@ protected function setUp(): void
$this->httpQueryHandler = new HttpQueryHandler($this->client);
}

/**
* @test
*/
#[Test]
public function shouldFetchHttpQuery(): void
{
$uri = 'some-url';
Expand All @@ -45,9 +44,7 @@ public function shouldFetchHttpQuery(): void
);
}

/**
* @test
*/
#[Test]
public function shouldFetchHttpQueryAsErrorWithBadRequest(): void
{
$uri = 'some-url';
Expand Down Expand Up @@ -76,9 +73,7 @@ public function shouldFetchHttpQueryAsErrorWithBadRequest(): void
);
}

/**
* @test
*/
#[Test]
public function shouldFetchHttpQueryAsErrorWithServerError(): void
{
$uri = 'some-url';
Expand Down
Loading
Loading