Skip to content

Commit cb9f754

Browse files
authored
Merge pull request #60 from list-interop/upgrade-phpunit
Upgrade PHPUnit to 10.2.x
2 parents d425418 + 1e8b96f commit cb9f754

File tree

8 files changed

+283
-372
lines changed

8 files changed

+283
-372
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"psr/http-client-implementation": "*",
2323
"psr/http-factory": "^1.0",
2424
"psr/http-message": "^1.1 || ^2.0",
25-
"webmozart/assert": "^1.10"
25+
"webmozart/assert": "^1.11"
2626
},
2727
"provide": {
2828
"symfony/polyfill-php73": "*"
@@ -33,7 +33,7 @@
3333
"ergebnis/composer-normalize": "^2.31",
3434
"laminas/laminas-diactoros": "^3.0.0",
3535
"php-http/curl-client": "^2.3",
36-
"phpunit/phpunit": "^9.6.9",
36+
"phpunit/phpunit": "^10.2.2",
3737
"psalm/plugin-phpunit": "^0.18.4",
3838
"react/child-process": "^0.6.5",
3939
"react/http": "^1.9",

composer.lock

Lines changed: 229 additions & 353 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml.dist

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".cache/test-results"
5+
cacheDirectory=".cache/phpunit"
66
failOnWarning="true"
7-
verbose="true">
7+
failOnNotice="true"
8+
failOnDeprecation="true"
9+
displayDetailsOnSkippedTests="true"
10+
displayDetailsOnTestsThatTriggerDeprecations="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
displayDetailsOnTestsThatTriggerNotices="true"
13+
displayDetailsOnTestsThatTriggerWarnings="true"
14+
displayDetailsOnIncompleteTests="true"
15+
>
816
<testsuites>
917
<testsuite name="Unit">
1018
<directory>test/Unit</directory>
@@ -14,10 +22,9 @@
1422
</testsuite>
1523
</testsuites>
1624

17-
<coverage cacheDirectory=".cache/code-coverage"
18-
processUncoveredFiles="true">
25+
<source>
1926
<include>
2027
<directory suffix=".php">src</directory>
2128
</include>
22-
</coverage>
29+
</source>
2330
</phpunit>

psalm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
xmlns="https://getpsalm.org/schema/config"
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
88
errorBaseline="psalm-baseline.xml"
9+
findUnusedCode="true"
10+
findUnusedPsalmSuppress="true"
11+
findUnusedBaselineEntry="true"
912
>
1013
<projectFiles>
1114
<directory name="src" />

src/Exception/ResponseError.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@
1010
use RuntimeException;
1111
use Throwable;
1212

13-
/** @internal */
1413
abstract class ResponseError extends RuntimeException implements ConvertKitError
1514
{
1615
protected RequestInterface|null $request = null;
1716
protected ResponseInterface|null $response = null;
1817

18+
/** @internal */
1919
final public function __construct(string $message, int $code, ?Throwable $previous = null) // phpcs:ignore
2020
{
2121
parent::__construct($message, $code, $previous);
2222
}
2323

24-
/** @return static */
24+
/**
25+
* @internal
26+
*
27+
* @return static
28+
*/
2529
final protected static function withHttpExchange(
2630
string $message,
2731
RequestInterface $request,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Exception;
6+
7+
use Laminas\Diactoros\Request;
8+
use Laminas\Diactoros\Response;
9+
use ListInterop\ConvertKit\Exception\ApiError;
10+
use PHPUnit\Framework\TestCase;
11+
12+
class ResponseErrorTest extends TestCase
13+
{
14+
public function testThatTheRequestAndResponseCanBeRetrieved(): void
15+
{
16+
$request = new Request();
17+
$response = new Response();
18+
19+
$error = ApiError::fromExchange($request, $response);
20+
21+
self::assertSame($request, $error->request());
22+
self::assertSame($response, $error->response());
23+
}
24+
}

test/Integration/HttpClient.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,4 @@ public function lastRequest(): RequestInterface|null
3434
{
3535
return $this->lastRequest;
3636
}
37-
38-
public function lastResponse(): ResponseInterface|null
39-
{
40-
return $this->lastResponse;
41-
}
4237
}

test/Unit/Container/ClientFactoryTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Laminas\Diactoros\RequestFactory;
99
use Laminas\Diactoros\StreamFactory;
1010
use Laminas\Diactoros\UriFactory;
11+
use ListInterop\ConvertKit\Client as ConvertKitClient;
1112
use ListInterop\ConvertKit\Container\ClientFactory;
1213
use ListInterop\ConvertKit\Exception\AssertionFailed;
1314
use PHPUnit\Framework\MockObject\MockObject;
@@ -32,7 +33,7 @@ protected function setUp(): void
3233
}
3334

3435
/** @return array<string, array{0: bool, 1: mixed, 2: string}> */
35-
public function erroneousConfig(): array
36+
public static function erroneousConfig(): array
3637
{
3738
return [
3839
'No Config' => [
@@ -108,7 +109,7 @@ public function testThatTheContainerMustHaveConfiguration(bool $has, mixed $get,
108109

109110
$this->expectException(AssertionFailed::class);
110111
$this->expectExceptionMessage($expectedErrorMessage);
111-
($this->factory)($this->container);
112+
$this->factory->__invoke($this->container);
112113
}
113114

114115
public function testClientCreationWillProceedWhenTheContainerHasAllRequiredDependencies(): void
@@ -127,7 +128,8 @@ public function testClientCreationWillProceedWhenTheContainerHasAllRequiredDepen
127128
[StreamFactoryInterface::class, new StreamFactory()],
128129
]);
129130

130-
($this->factory)($this->container);
131+
$client = $this->factory->__invoke($this->container);
132+
self::assertInstanceOf(ConvertKitClient::class, $client);
131133
}
132134

133135
public function testClientCreationWillProceedWhenOnlyConfigIsAvailable(): void
@@ -145,7 +147,7 @@ public function testClientCreationWillProceedWhenOnlyConfigIsAvailable(): void
145147
->method('get')
146148
->willReturn(['convertkit' => ['api-key' => 'foo', 'secret-key' => 'bar']]);
147149

148-
($this->factory)($this->container);
150+
$this->factory->__invoke($this->container);
149151
}
150152

151153
public function testAnAssertionErrorWillBeThrownWhenTheContainerSendsSomethingWeird(): void
@@ -162,6 +164,6 @@ public function testAnAssertionErrorWillBeThrownWhenTheContainerSendsSomethingWe
162164
]);
163165

164166
$this->expectException(AssertionFailed::class);
165-
($this->factory)($this->container);
167+
$this->factory->__invoke($this->container);
166168
}
167169
}

0 commit comments

Comments
 (0)