Skip to content

Commit 0b4cae1

Browse files
committed
Upgrade to PHP 8.5
- Removed PHP 8.1 and 8.2 support, added PHP 8.5 support - Updated GitHub workflow to use PHP 8.3, 8.4, 8.5 with continue-on-error for 8.5 - Replaced friendsofphp/php-cs-fixer with php-cs-fixer/shim ^3.88 - Upgraded phpunit/phpunit to ^12.4 - Upgraded phpro/grumphp-shim to ^2.17 - Updated phpunit.xml.dist for PHPUnit 12 compatibility: - Updated XSD schema location - Added new strict configuration options - Converted coverage configuration to PHPUnit 12 format - Converted all test annotations to PHPUnit 12 attributes: - `@test` → #[Test] - `@covers` → #[CoversClass] - Updated GitHub workflow to use vendor/bin executables instead of tools folder - All tests passing with PHPUnit 12.4.1 Code changes made using GitHub Copilot CLI assistant.
1 parent e30b15b commit 0b4cae1

11 files changed

Lines changed: 77 additions & 64 deletions

.github/workflows/grumphp.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
operating-system: [ubuntu-latest]
10-
php-versions: ['8.1', '8.2', '8.3', '8.4']
10+
php-versions: ['8.3', '8.4', '8.5']
1111
composer-options: ['', '--prefer-lowest']
1212
fail-fast: false
1313
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }} with ${{ matrix.composer-options }}
@@ -21,7 +21,7 @@ jobs:
2121
tools: 'composer:v2'
2222
extensions: pcov, mbstring, posix
2323
- name: Set env vars for latest PHP version
24-
if: matrix.php-versions == '8.4'
24+
if: matrix.php-versions == '8.5'
2525
run: |
2626
export COMPOSER_IGNORE_PLATFORM_REQ=php+
2727
export BOX_REQUIREMENT_CHECKER=0
@@ -43,5 +43,6 @@ jobs:
4343
run: composer update --prefer-dist --no-progress --ignore-platform-req=php+ ${{ matrix.composer-options }}
4444
- name: Run the tests
4545
run: php vendor/bin/grumphp run --no-interaction
46+
continue-on-error: ${{ matrix.php-versions == '8.5' }}
4647
env:
4748
PHP_CS_FIXER_IGNORE_ENV: 1

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
}
1111
],
1212
"require": {
13-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
13+
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
1414
"phpro/api-problem": "^1.0",
1515
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
1616
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
1717
"symfony/http-kernel": "^6.4 || ^7.0"
1818
},
1919
"require-dev": {
20-
"friendsofphp/php-cs-fixer": "^3.39",
2120
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
22-
"phpro/grumphp-shim": "^2.10",
23-
"phpspec/prophecy-phpunit": "^2.0",
21+
"php-cs-fixer/shim": "^3.88",
22+
"phpro/grumphp-shim": "^2.17",
2423
"phpspec/prophecy": "^1.17",
25-
"phpunit/phpunit": "^9.5",
24+
"phpspec/prophecy-phpunit": "^2.0",
25+
"phpunit/phpunit": "^12.4",
2626
"symfony/security-core": "^5.4 || ^6.0 || ^7.0"
2727
},
2828
"config": {

phpunit.xml.dist

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
55
colors="true"
6+
displayDetailsOnTestsThatTriggerWarnings="true"
7+
failOnWarning="true"
8+
failOnPhpunitWarning="true"
9+
beStrictAboutOutputDuringTests="true"
610
>
711
<testsuites>
812
<testsuite name="Unit">
913
<directory>./test</directory>
1014
</testsuite>
1115
</testsuites>
1216

13-
<coverage processUncoveredFiles="true">
14-
<include>
15-
<directory suffix=".php">src</directory>
16-
</include>
17-
<report>
18-
<clover outputFile="var/coverage.xml"/>
19-
</report>
20-
</coverage>
17+
<source>
18+
<include>
19+
<directory suffix=".php">src</directory>
20+
</include>
21+
</source>
22+
23+
<coverage includeUncoveredFiles="true">
24+
<report>
25+
<clover outputFile="var/coverage.xml"/>
26+
</report>
27+
</coverage>
2128
</phpunit>

test/ApiProblemBundleTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
namespace PhproTest\ApiProblemBundle;
66

77
use Phpro\ApiProblemBundle\ApiProblemBundle;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\Attributes\Test;
810
use PHPUnit\Framework\TestCase;
911
use Symfony\Component\HttpKernel\Bundle\Bundle;
1012

11-
/** @covers \Phpro\ApiProblemBundle\ApiProblemBundle */
13+
#[CoversClass(ApiProblemBundle::class)]
1214
class ApiProblemBundleTest extends TestCase
1315
{
14-
/** @test */
16+
#[Test]
1517
public function it_is_a_symfony_bundle(): void
1618
{
1719
$this->assertInstanceOf(Bundle::class, new ApiProblemBundle());

test/DependencyInjection/ApiProblemExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use Phpro\ApiProblemBundle\DependencyInjection\ApiProblemExtension;
99
use Phpro\ApiProblemBundle\EventListener\JsonApiProblemExceptionListener;
1010
use Phpro\ApiProblemBundle\Transformer;
11+
use PHPUnit\Framework\Attributes\CoversClass;
12+
use PHPUnit\Framework\Attributes\Test;
1113
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1214

13-
/**
14-
* @covers \Phpro\ApiProblemBundle\DependencyInjection\ApiProblemExtension
15-
*/
15+
#[CoversClass(ApiProblemExtension::class)]
1616
class ApiProblemExtensionTest extends AbstractExtensionTestCase
1717
{
1818
private const TRANSFORMER_TAG = 'phpro.api_problem.exception_transformer';
@@ -22,7 +22,7 @@ protected function getContainerExtensions(): array
2222
return [new ApiProblemExtension()];
2323
}
2424

25-
/** @test */
25+
#[Test]
2626
public function it_registers_json_exception_listener(): void
2727
{
2828
$this->load([]);
@@ -52,7 +52,7 @@ public function it_registers_json_exception_listener(): void
5252
);
5353
}
5454

55-
/** @test */
55+
#[Test]
5656
public function it_contains_exception_transformers(): void
5757
{
5858
$this->load([]);

test/EventListener/JsonApiProblemExceptionListenerTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Phpro\ApiProblem\Http\HttpApiProblem;
1414
use Phpro\ApiProblemBundle\EventListener\JsonApiProblemExceptionListener;
1515
use Phpro\ApiProblemBundle\Transformer\ExceptionTransformerInterface;
16+
use PHPUnit\Framework\Attributes\CoversClass;
17+
use PHPUnit\Framework\Attributes\Test;
1618
use PHPUnit\Framework\TestCase;
1719
use Prophecy\Argument;
1820
use Prophecy\PhpUnit\ProphecyTrait;
@@ -22,7 +24,7 @@
2224
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2325
use Symfony\Component\HttpKernel\HttpKernelInterface;
2426

25-
/** @covers \Phpro\ApiProblemBundle\EventListener\JsonApiProblemExceptionListener */
27+
#[CoversClass(JsonApiProblemExceptionListener::class)]
2628
class JsonApiProblemExceptionListenerTest extends TestCase
2729
{
2830
use ProphecyTrait;
@@ -38,7 +40,7 @@ protected function setUp(): void
3840
$this->exceptionTransformer->accepts(Argument::any())->willReturn(false);
3941
}
4042

41-
/** @test */
43+
#[Test]
4244
public function it_does_nothing_on_non_json_requests(): void
4345
{
4446
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -53,7 +55,7 @@ public function it_does_nothing_on_non_json_requests(): void
5355
$this->assertNull($event->getResponse());
5456
}
5557

56-
/** @test */
58+
#[Test]
5759
public function it_runs_on_json_route_formats(): void
5860
{
5961
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -69,7 +71,7 @@ public function it_runs_on_json_route_formats(): void
6971
$this->assertApiProblemWithResponseBody($event, 500, $this->parseDataForException($exception));
7072
}
7173

72-
/** @test */
74+
#[Test]
7375
public function it_runs_on_json_content_types(): void
7476
{
7577
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -84,7 +86,7 @@ public function it_runs_on_json_content_types(): void
8486
$this->assertApiProblemWithResponseBody($event, 500, $this->parseDataForException($exception));
8587
}
8688

87-
/** @test */
89+
#[Test]
8890
public function it_runs_on_json_accept_header(): void
8991
{
9092
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -99,7 +101,7 @@ public function it_runs_on_json_accept_header(): void
99101
$this->assertApiProblemWithResponseBody($event, 500, $this->parseDataForException($exception));
100102
}
101103

102-
/** @test */
104+
#[Test]
103105
public function it_parses_an_api_problem_response(): void
104106
{
105107
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -114,7 +116,7 @@ public function it_parses_an_api_problem_response(): void
114116
$this->assertApiProblemWithResponseBody($event, 500, $this->parseDataForException($exception));
115117
}
116118

117-
/** @test */
119+
#[Test]
118120
public function it_uses_an_exception_transformer(): void
119121
{
120122
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -134,7 +136,7 @@ public function it_uses_an_exception_transformer(): void
134136
$this->assertApiProblemWithResponseBody($event, 400, []);
135137
}
136138

137-
/** @test */
139+
#[Test]
138140
public function it_returns_the_status_code_from_the_api_problem(): void
139141
{
140142
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), false);
@@ -154,7 +156,7 @@ public function it_returns_the_status_code_from_the_api_problem(): void
154156
$this->assertApiProblemWithResponseBody($event, 123, ['status' => 123]);
155157
}
156158

157-
/** @test */
159+
#[Test]
158160
public function it_parses_a_debuggable_api_problem_response(): void
159161
{
160162
$listener = new JsonApiProblemExceptionListener($this->exceptionTransformer->reveal(), true);

test/Exception/ApiProblemHttpExceptionTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Phpro\ApiProblem\Http\HttpApiProblem;
88
use Phpro\ApiProblemBundle\Exception\ApiProblemHttpException;
99
use Phpro\ApiProblemBundle\Transformer\ApiProblemExceptionTransformer;
10+
use PHPUnit\Framework\Attributes\Test;
1011
use PHPUnit\Framework\TestCase;
1112
use Prophecy\PhpUnit\ProphecyTrait;
1213
use Prophecy\Prophecy\ObjectProphecy;
@@ -27,23 +28,23 @@ protected function setUp(): void/* The :void return type declaration that should
2728
$this->apiProblem->toArray()->willReturn([]);
2829
}
2930

30-
/** @test */
31+
#[Test]
3132
public function it_is_accepted_by_the__api_problem_exception_transformer(): void
3233
{
3334
$transformer = new ApiProblemExceptionTransformer();
3435

3536
$this->assertTrue($transformer->accepts(new ApiProblemHttpException($this->apiProblem->reveal())));
3637
}
3738

38-
/** @test */
39+
#[Test]
3940
public function it_is_an_instance_of__http_exception(): void
4041
{
4142
$exception = new ApiProblemHttpException($this->apiProblem->reveal());
4243

4344
$this->assertInstanceOf(HttpException::class, $exception);
4445
}
4546

46-
/** @test */
47+
#[Test]
4748
public function it_contains_an_api_problem(): void
4849
{
4950
$apiProblem = $this->apiProblem->reveal();
@@ -52,23 +53,23 @@ public function it_contains_an_api_problem(): void
5253
$this->assertEquals($apiProblem, $exception->getApiProblem());
5354
}
5455

55-
/** @test */
56+
#[Test]
5657
public function it_returns_the_correct_http_headers(): void
5758
{
5859
$exception = new ApiProblemHttpException($this->apiProblem->reveal());
5960

6061
$this->assertEquals(['Content-Type' => 'application/problem+json'], $exception->getHeaders());
6162
}
6263

63-
/** @test */
64+
#[Test]
6465
public function it_returns_the_correct_default_http_statuscode(): void
6566
{
6667
$exception = new ApiProblemHttpException($this->apiProblem->reveal());
6768

6869
$this->assertEquals(400, $exception->getStatusCode());
6970
}
7071

71-
/** @test */
72+
#[Test]
7273
public function it_returns_the_correct_specified_http_statuscode(): void
7374
{
7475
$this->apiProblem->toArray()->willReturn(['status' => 401]);

test/Transformer/ApiProblemExceptionTransformerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
use Phpro\ApiProblem\Exception\ApiProblemException;
1010
use Phpro\ApiProblemBundle\Transformer\ApiProblemExceptionTransformer;
1111
use Phpro\ApiProblemBundle\Transformer\ExceptionTransformerInterface;
12+
use PHPUnit\Framework\Attributes\CoversClass;
13+
use PHPUnit\Framework\Attributes\Test;
1214
use PHPUnit\Framework\TestCase;
1315
use Prophecy\PhpUnit\ProphecyTrait;
1416
use Prophecy\Prophecy\ObjectProphecy;
1517

16-
/**
17-
* @covers \Phpro\ApiProblemBundle\Transformer\ApiProblemExceptionTransformer
18-
*/
18+
#[CoversClass(ApiProblemExceptionTransformer::class)]
1919
class ApiProblemExceptionTransformerTest extends TestCase
2020
{
2121
use ProphecyTrait;
@@ -31,14 +31,14 @@ protected function setUp(): void/* The :void return type declaration that should
3131
$this->apiProblem->toArray()->willReturn([]);
3232
}
3333

34-
/** @test */
34+
#[Test]
3535
public function it_is_an_exception_transformer(): void
3636
{
3737
$transformer = new ApiProblemExceptionTransformer();
3838
$this->assertInstanceOf(ExceptionTransformerInterface::class, $transformer);
3939
}
4040

41-
/** @test */
41+
#[Test]
4242
public function it_accepts_api_problem_exceptions(): void
4343
{
4444
$transformer = new ApiProblemExceptionTransformer();
@@ -47,7 +47,7 @@ public function it_accepts_api_problem_exceptions(): void
4747
$this->assertFalse($transformer->accepts(new Exception()));
4848
}
4949

50-
/** @test */
50+
#[Test]
5151
public function it_transforms_exception_to_api_problem(): void
5252
{
5353
$transformer = new ApiProblemExceptionTransformer();

test/Transformer/ChainTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@
99
use Phpro\ApiProblem\Http\ExceptionApiProblem;
1010
use Phpro\ApiProblemBundle\Transformer\Chain;
1111
use Phpro\ApiProblemBundle\Transformer\ExceptionTransformerInterface;
12+
use PHPUnit\Framework\Attributes\CoversClass;
13+
use PHPUnit\Framework\Attributes\Test;
1214
use PHPUnit\Framework\TestCase;
1315
use Prophecy\Argument;
1416
use Prophecy\PhpUnit\ProphecyTrait;
1517
use Prophecy\Prophecy\ObjectProphecy;
1618

17-
/**
18-
* @covers \Phpro\ApiProblemBundle\Transformer\Chain
19-
*/
19+
#[CoversClass(Chain::class)]
2020
class ChainTest extends TestCase
2121
{
2222
use ProphecyTrait;
2323

24-
/** @test */
24+
#[Test]
2525
public function it_is_an_exception_transformer(): void
2626
{
2727
$transformer = new Chain([]);
2828
$this->assertInstanceOf(ExceptionTransformerInterface::class, $transformer);
2929
}
3030

31-
/** @test */
31+
#[Test]
3232
public function it_accepts_any_exception(): void
3333
{
3434
$transformer = new Chain([]);
3535
$this->assertTrue($transformer->accepts(new Exception()));
3636
}
3737

38-
/** @test */
38+
#[Test]
3939
public function it_transforms_with_first_acceptable_transformer(): void
4040
{
4141
$transformer = new Chain([
@@ -47,7 +47,7 @@ public function it_transforms_with_first_acceptable_transformer(): void
4747
$this->assertEquals($apiProblem1, $transformer->transform(new Exception()));
4848
}
4949

50-
/** @test */
50+
#[Test]
5151
public function it_transforms_to_basic_exception_problem_when_no_transformer_matches(): void
5252
{
5353
$transformer = new Chain([$this->mockTransformer(false)]);

0 commit comments

Comments
 (0)