Skip to content

Commit c876f99

Browse files
beschoenenlindyhopchris
authored andcommitted
feat: support phpunit 12
1 parent ce8524a commit c876f99

File tree

8 files changed

+30
-24
lines changed

8 files changed

+30
-24
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
matrix:
2020
php: [8.2, 8.3, 8.4]
2121
laravel: [10, 11, 12]
22-
phpunit: [10.5, 11]
22+
phpunit: [10.5, 11, 12]
2323

2424
steps:
2525
- name: Checkout Code

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"ext-json": "*",
2626
"illuminate/contracts": "^10.0|^11.0|^12.0",
2727
"illuminate/support": "^10.0|^11.0|^12.0",
28-
"phpunit/phpunit": "^10.5|^11.0"
28+
"phpunit/phpunit": "^10.5|^11.0|^12.0"
2929
},
3030
"autoload": {
3131
"psr-4": {

tests/Assertions/FetchedManyTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CloudCreativity\JsonApi\Testing\Tests\TestCase;
1818
use CloudCreativity\JsonApi\Testing\Tests\TestModel;
1919
use Illuminate\Support\Collection;
20+
use PHPUnit\Framework\Attributes\DataProvider;
2021

2122
class FetchedManyTest extends TestCase
2223
{
@@ -363,8 +364,8 @@ function ($post1, $post2, $post3) {
363364
* @param bool $expected
364365
* @param Closure $provider
365366
* @return void
366-
* @dataProvider fetchedManyArrayProvider
367367
*/
368+
#[DataProvider('fetchedManyArrayProvider')]
368369
public function testFetchedManyWithArray(bool $expected, Closure $provider): void
369370
{
370371
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -383,8 +384,8 @@ public function testFetchedManyWithArray(bool $expected, Closure $provider): voi
383384
* @param bool $expected
384385
* @param Closure $provider
385386
* @return void
386-
* @dataProvider fetchedManyArrayProvider
387387
*/
388+
#[DataProvider('fetchedManyArrayProvider')]
388389
public function testFetchedManyWithObject(bool $expected, Closure $provider): void
389390
{
390391
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -677,8 +678,8 @@ function ($post1, $post2, $post3) {
677678
* @param bool $expected
678679
* @param Closure $provider
679680
* @return void
680-
* @dataProvider fetchedManyInOrderArrayProvider
681681
*/
682+
#[DataProvider('fetchedManyInOrderArrayProvider')]
682683
public function testFetchedManyInOrderWithArray(bool $expected, Closure $provider): void
683684
{
684685
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -697,8 +698,8 @@ public function testFetchedManyInOrderWithArray(bool $expected, Closure $provide
697698
* @param bool $expected
698699
* @param Closure $provider
699700
* @return void
700-
* @dataProvider fetchedManyInOrderArrayProvider
701701
*/
702+
#[DataProvider('fetchedManyInOrderArrayProvider')]
702703
public function testFetchedManyInOrderWithObject(bool $expected, Closure $provider): void
703704
{
704705
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -879,8 +880,8 @@ function ($post1, $post2, $post3) {
879880
* @param bool $expected
880881
* @param Closure $provider
881882
* @return void
882-
* @dataProvider fetchedManyExactArrayProvider
883883
*/
884+
#[DataProvider('fetchedManyExactArrayProvider')]
884885
public function testFetchedManyExactWithArray(bool $expected, Closure $provider): void
885886
{
886887
$value = $provider($this->post1, $this->post2, $this->post3);

tests/Assertions/FetchedOneTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use CloudCreativity\JsonApi\Testing\Tests\TestModel;
1919
use CloudCreativity\JsonApi\Testing\Tests\TestObject;
2020
use Illuminate\Support\Collection;
21+
use PHPUnit\Framework\Attributes\DataProvider;
2122

2223
class FetchedOneTest extends TestCase
2324
{
@@ -244,8 +245,8 @@ function (array $resource) {
244245
* @param bool $expected
245246
* @param Closure $provider
246247
* @return void
247-
* @dataProvider fetchedOneArrayProvider
248248
*/
249+
#[DataProvider('fetchedOneArrayProvider')]
249250
public function testFetchedOneWithArray(bool $expected, Closure $provider): void
250251
{
251252
$value = $provider($this->resource);
@@ -264,8 +265,8 @@ public function testFetchedOneWithArray(bool $expected, Closure $provider): void
264265
* @param bool $expected
265266
* @param Closure $provider
266267
* @return void
267-
* @dataProvider fetchedOneArrayProvider
268268
*/
269+
#[DataProvider('fetchedOneArrayProvider')]
269270
public function testFetchedOneWithObject(bool $expected, Closure $provider): void
270271
{
271272
$value = $provider($this->resource);
@@ -426,8 +427,8 @@ function (array $resource) {
426427
* @param bool $expected
427428
* @param Closure $provider
428429
* @return void
429-
* @dataProvider fetchedOneExactArrayProvider
430430
*/
431+
#[DataProvider('fetchedOneExactArrayProvider')]
431432
public function testFetchedOneExactWithArray(bool $expected, Closure $provider): void
432433
{
433434
$value = $provider($this->resource);
@@ -446,8 +447,8 @@ public function testFetchedOneExactWithArray(bool $expected, Closure $provider):
446447
* @param bool $expected
447448
* @param Closure $provider
448449
* @return void
449-
* @dataProvider fetchedOneExactArrayProvider
450450
*/
451+
#[DataProvider('fetchedOneExactArrayProvider')]
451452
public function testFetchedOneExactWithObject(bool $expected, Closure $provider): void
452453
{
453454
$value = $provider($this->resource);

tests/Assertions/FetchedToManyTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CloudCreativity\JsonApi\Testing\Tests\TestCase;
1717
use CloudCreativity\JsonApi\Testing\Tests\TestModel;
1818
use Illuminate\Support\Collection;
19+
use PHPUnit\Framework\Attributes\DataProvider;
1920

2021
class FetchedToManyTest extends TestCase
2122
{
@@ -199,8 +200,8 @@ public static function fetchedToManyArrayProvider(): array
199200
* @param bool $expected
200201
* @param Closure $provider
201202
* @return void
202-
* @dataProvider fetchedToManyArrayProvider
203203
*/
204+
#[DataProvider('fetchedToManyArrayProvider')]
204205
public function testFetchedToManyWithArray(bool $expected, Closure $provider): void
205206
{
206207
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -219,8 +220,8 @@ public function testFetchedToManyWithArray(bool $expected, Closure $provider): v
219220
* @param bool $expected
220221
* @param Closure $provider
221222
* @return void
222-
* @dataProvider fetchedToManyArrayProvider
223223
*/
224+
#[DataProvider('fetchedToManyArrayProvider')]
224225
public function testFetchedToManyWithObject(bool $expected, Closure $provider): void
225226
{
226227
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -383,8 +384,8 @@ public static function fetchedToManyInOrderArrayProvider(): array
383384
* @param bool $expected
384385
* @param Closure $provider
385386
* @return void
386-
* @dataProvider fetchedToManyInOrderArrayProvider
387387
*/
388+
#[DataProvider('fetchedToManyInOrderArrayProvider')]
388389
public function testFetchedToManyInOrderWithArray(bool $expected, Closure $provider): void
389390
{
390391
$value = $provider($this->post1, $this->post2, $this->post3);
@@ -403,8 +404,8 @@ public function testFetchedToManyInOrderWithArray(bool $expected, Closure $provi
403404
* @param bool $expected
404405
* @param Closure $provider
405406
* @return void
406-
* @dataProvider fetchedToManyInOrderArrayProvider
407407
*/
408+
#[DataProvider('fetchedToManyInOrderArrayProvider')]
408409
public function testFetchedToManyInOrderWithObject(bool $expected, Closure $provider): void
409410
{
410411
$value = $provider($this->post1, $this->post2, $this->post3);

tests/Assertions/FetchedToOneTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CloudCreativity\JsonApi\Testing\Tests\TestModel;
1818
use CloudCreativity\JsonApi\Testing\Tests\TestObject;
1919
use Illuminate\Support\Collection;
20+
use PHPUnit\Framework\Attributes\DataProvider;
2021

2122
class FetchedToOneTest extends TestCase
2223
{
@@ -130,8 +131,8 @@ public static function fetchedToOneArrayProvider(): array
130131
* @param bool $expected
131132
* @param Closure $provider
132133
* @return void
133-
* @dataProvider fetchedToOneArrayProvider
134134
*/
135+
#[DataProvider('fetchedToOneArrayProvider')]
135136
public function testFetchedOneWithArray(bool $expected, Closure $provider): void
136137
{
137138
$value = $provider($this->identifier);
@@ -150,8 +151,8 @@ public function testFetchedOneWithArray(bool $expected, Closure $provider): void
150151
* @param bool $expected
151152
* @param Closure $provider
152153
* @return void
153-
* @dataProvider fetchedToOneArrayProvider
154154
*/
155+
#[DataProvider('fetchedToOneArrayProvider')]
155156
public function testFetchedOneWithObject(bool $expected, Closure $provider): void
156157
{
157158
$value = $provider($this->identifier);
@@ -230,8 +231,8 @@ public static function resourceProvider(): array
230231
/**
231232
* @param Closure $provider
232233
* @return void
233-
* @dataProvider resourceProvider
234234
*/
235+
#[DataProvider('resourceProvider')]
235236
public function testFetchedToOneWithResource(Closure $provider): void
236237
{
237238
$value = $provider($this->identifier);

tests/Assertions/IncludedTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CloudCreativity\JsonApi\Testing\Tests\TestCase;
1717
use CloudCreativity\JsonApi\Testing\Tests\TestModel;
1818
use Illuminate\Support\Collection;
19+
use PHPUnit\Framework\Attributes\DataProvider;
1920

2021
class IncludedTest extends TestCase
2122
{
@@ -162,8 +163,8 @@ public static function isIncludedProvider(): array
162163
* @param string $type
163164
* @param string $id
164165
* @return void
165-
* @dataProvider isIncludedProvider
166166
*/
167+
#[DataProvider('isIncludedProvider')]
167168
public function testIsIncludedWithUrlRoutable(bool $expected, string $type, string $id): void
168169
{
169170
$model = new TestModel((int) $id);
@@ -183,8 +184,8 @@ public function testIsIncludedWithUrlRoutable(bool $expected, string $type, stri
183184
* @param string $type
184185
* @param string $id
185186
* @return void
186-
* @dataProvider isIncludedProvider
187187
*/
188+
#[DataProvider('isIncludedProvider')]
188189
public function testIsIncludedWithString(bool $expected, string $type, string $id): void
189190
{
190191
if ($expected) {
@@ -202,8 +203,8 @@ public function testIsIncludedWithString(bool $expected, string $type, string $i
202203
* @param string $type
203204
* @param string $id
204205
* @return void
205-
* @dataProvider isIncludedProvider
206206
*/
207+
#[DataProvider('isIncludedProvider')]
207208
public function testIsIncludedWithInteger(bool $expected, string $type, string $id): void
208209
{
209210
$id = (int) $id;

tests/Assertions/MetaTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use CloudCreativity\JsonApi\Testing\HttpMessage;
1616
use CloudCreativity\JsonApi\Testing\Tests\TestCase;
1717
use CloudCreativity\JsonApi\Testing\Tests\TestObject;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819

1920
class MetaTest extends TestCase
2021
{
@@ -82,8 +83,8 @@ public static function statusCodeProvider(): array
8283
/**
8384
* @param int $status
8485
* @return void
85-
* @dataProvider statusCodeProvider
8686
*/
87+
#[DataProvider('statusCodeProvider')]
8788
public function testMetaWithoutData(int $status): void
8889
{
8990
$http = $this->http->withStatusCode($status);
@@ -109,8 +110,8 @@ public function testMetaWithoutData(int $status): void
109110
/**
110111
* @param int $status
111112
* @return void
112-
* @dataProvider statusCodeProvider
113113
*/
114+
#[DataProvider('statusCodeProvider')]
114115
public function testExactMetaWithoutData(int $status): void
115116
{
116117
$http = $this->http->withStatusCode($status);
@@ -160,8 +161,8 @@ public static function invalidStatusCodeProvider(): array
160161
* @param int $status
161162
* @param string $expected
162163
* @return void
163-
* @dataProvider invalidStatusCodeProvider
164164
*/
165+
#[DataProvider('invalidStatusCodeProvider')]
165166
public function testInvalidStatusCode(int $status, string $expected = ''): void
166167
{
167168
$expected = $expected ?: "HTTP status {$status} is successful";

0 commit comments

Comments
 (0)