Skip to content

Commit 63e764a

Browse files
committed
replace dataProvider annotations with DataProvider attribute
1 parent 8a18b4c commit 63e764a

28 files changed

+83
-214
lines changed

tests/Functional/DotNotationTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ class DotNotationTest extends TestCase
2020
{
2121
use HelperTrait;
2222

23-
/**
24-
* @test
25-
*/
2623
public function testCompleteResourceObjectWithMultipleRelationships(): void
2724
{
2825
$manager = new ErrorAbortManager(new Factory());
@@ -189,9 +186,6 @@ public function testCompleteResourceObjectWithMultipleRelationships(): void
189186
$this->assertSame('http://example.com/comments/12', $document->get('included.2.links.self'));
190187
}
191188

192-
/**
193-
* @test
194-
*/
195189
public function testGetNotExistentValueThrowsException(): void
196190
{
197191
$manager = new ErrorAbortManager(new Factory());

tests/Functional/ErrorParsingTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ class ErrorParsingTest extends TestCase
1616
{
1717
use HelperTrait;
1818

19-
/**
20-
* @test
21-
*/
2219
public function testParseErrors(): void
2320
{
2421
$string = $this->getJsonString('09_errors.json');
@@ -89,9 +86,6 @@ public function testParseErrors(): void
8986
$this->assertFalse($errors->has('3'));
9087
}
9188

92-
/**
93-
* @test
94-
*/
9589
public function testParseErrorWithLinks(): void
9690
{
9791
$string = $this->getJsonString('10_error_with_links.json');

tests/Functional/ParsingTest.php

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Art4\JsonApiClient\Manager\ErrorAbortManager;
1515
use Art4\JsonApiClient\Tests\Fixtures\HelperTrait;
1616
use Art4\JsonApiClient\V1\Factory;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1718
use PHPUnit\Framework\TestCase;
1819

1920
class ParsingTest extends TestCase
@@ -38,9 +39,7 @@ public static function createParserProvider(): array
3839
];
3940
}
4041

41-
/**
42-
* @dataProvider createParserProvider
43-
*/
42+
#[DataProvider('createParserProvider')]
4443
public function testParseSimpleResourceWithDifferentParser(callable $parser): void
4544
{
4645
$string = $this->getJsonString('01_simple_resource.json');
@@ -67,9 +66,6 @@ public function testParseSimpleResourceWithDifferentParser(callable $parser): vo
6766
$this->assertInstanceOf('Art4\JsonApiClient\V1\RelationshipCollection', $resource->get('relationships'));
6867
}
6968

70-
/**
71-
* @test
72-
*/
7369
public function testParseSimpleResourceIdentifier(): void
7470
{
7571
$string = $this->getJsonString('02_simple_resource_identifier.json');
@@ -91,9 +87,6 @@ public function testParseSimpleResourceIdentifier(): void
9187
$this->assertSame($resource->get('id'), '1');
9288
}
9389

94-
/**
95-
* @test
96-
*/
9790
public function testParseResourceObject(): void
9891
{
9992
$string = $this->getJsonString('03_resource_object.json');
@@ -159,9 +152,6 @@ public function testParseResourceObject(): void
159152
$this->assertSame($data->get('id'), '9');
160153
}
161154

162-
/**
163-
* @test
164-
*/
165155
public function testParseCompleteResourceObjectWithMultipleRelationships(): void
166156
{
167157
$string = $this->getJsonString('04_complete_document_with_multiple_relationships.json');
@@ -355,9 +345,6 @@ public function testParseCompleteResourceObjectWithMultipleRelationships(): void
355345
$this->assertSame($links->get('self'), 'http://example.com/comments/12');
356346
}
357347

358-
/**
359-
* @test
360-
*/
361348
public function testParsePaginationExample(): void
362349
{
363350
$string = $this->getJsonString('06_pagination_example.json');
@@ -409,9 +396,6 @@ public function testParsePaginationExample(): void
409396
$this->assertSame($links->get('last'), 'http://example.com/articles?page[number]=13&page[size]=1');
410397
}
411398

412-
/**
413-
* @test
414-
*/
415399
public function testParseRelationshipExample(): void
416400
{
417401
$string = $this->getJsonString('07_relationship_example_without_data.json');
@@ -475,9 +459,6 @@ public function testParseRelationshipExample(): void
475459
$this->assertSame($document->get('data.0.relationships.comments.links.related.meta.count'), 10);
476460
}
477461

478-
/**
479-
* @test
480-
*/
481462
public function testParseObjectLinksExample(): void
482463
{
483464
$string = $this->getJsonString('08_object_links.json');
@@ -518,9 +499,6 @@ public function testParseObjectLinksExample(): void
518499
$this->assertSame('bar', $document->get('jsonapi.meta.foo'));
519500
}
520501

521-
/**
522-
* @test
523-
*/
524502
public function testParseResourceIdentifierWithMeta(): void
525503
{
526504
$string = $this->getJsonString('11_resource_identifier_with_meta.json');
@@ -544,9 +522,6 @@ public function testParseResourceIdentifierWithMeta(): void
544522
$this->assertSame($resource->get('id'), '2');
545523
}
546524

547-
/**
548-
* @test
549-
*/
550525
public function testParseNullResource(): void
551526
{
552527
$string = $this->getJsonString('12_null_resource.json');
@@ -565,9 +540,6 @@ public function testParseNullResource(): void
565540
$this->assertInstanceOf('Art4\JsonApiClient\V1\ResourceNull', $resource);
566541
}
567542

568-
/**
569-
* @test
570-
*/
571543
public function testParseResourceIdentifierCollectionWithMeta(): void
572544
{
573545
$string = $this->getJsonString('13_collection_with_resource_identifier_with_meta.json');
@@ -602,9 +574,6 @@ public function testParseResourceIdentifierCollectionWithMeta(): void
602574
$this->assertSame($resource1->get('id'), '2');
603575
}
604576

605-
/**
606-
* @test
607-
*/
608577
public function testParseCreateResourceWithoutId(): void
609578
{
610579
$string = $this->getJsonString('14_create_resource_without_id.json');
@@ -614,9 +583,6 @@ public function testParseCreateResourceWithoutId(): void
614583
$this->assertSame(['data'], $document->getKeys());
615584
}
616585

617-
/**
618-
* @test
619-
*/
620586
public function testParseCreateShortResourceWithoutId(): void
621587
{
622588
$string = $this->getJsonString('15_create_resource_without_id.json');
@@ -626,19 +592,13 @@ public function testParseCreateShortResourceWithoutId(): void
626592
$this->assertSame(['data'], $document->getKeys());
627593
}
628594

629-
/**
630-
* @test
631-
*/
632595
public function testExceptionIfIdIsNotString(): void
633596
{
634597
$this->expectException(\Art4\JsonApiClient\Exception\ValidationException::class);
635598
$string = $this->getJsonString('16_type_and_id_as_integer.json');
636599
$document = Parser::parseResponseString($string);
637600
}
638601

639-
/**
640-
* @test
641-
*/
642602
public function testParseLinksInRelationshipsCorrectly(): void
643603
{
644604
$string = $this->getJsonString('17_relationship_links.json');

tests/Functional/SerializerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Art4\JsonApiClient\Tests\Fixtures\HelperTrait;
1616
use Art4\JsonApiClient\V1\Factory;
1717
use Exception;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\TestCase;
1920

2021
class SerializerTest extends TestCase
@@ -61,9 +62,7 @@ public static function jsonapiDataProvider(): array
6162
return $files;
6263
}
6364

64-
/**
65-
* @dataProvider jsonapiDataProvider
66-
*/
65+
#[DataProvider('jsonapiDataProvider')]
6766
public function testParseJsonapiDataWithErrorAbortManager(string $filename, bool $isRequest): void
6867
{
6968
$manager = new ErrorAbortManager(new Factory());

tests/Unit/Helper/AccessableTraitTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
use Art4\JsonApiClient\Exception\AccessException;
1212
use Art4\JsonApiClient\Tests\Fixtures\AccessableTraitMock;
1313
use Art4\JsonApiClient\Tests\Fixtures\HelperTrait;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516

1617
class AccessableTraitTest extends TestCase
1718
{
1819
use HelperTrait;
1920

20-
/**
21-
* @dataProvider jsonValuesProviderWithoutStringAndInt
22-
*/
21+
#[DataProvider('jsonValuesProviderWithoutStringAndInt')]
2322
public function testHasWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void
2423
{
2524
$resource = new AccessableTraitMock();
@@ -41,9 +40,7 @@ function ($errno, $errstr) use ($key): bool {
4140
$resource->has($key);
4241
}
4342

44-
/**
45-
* @dataProvider jsonValuesProviderWithoutStringAndInt
46-
*/
43+
#[DataProvider('jsonValuesProviderWithoutStringAndInt')]
4744
public function testGetWithInvalidKeyTypeTriggersDeprecationError(mixed $key): void
4845
{
4946
$resource = new AccessableTraitMock();

tests/Unit/Input/RequestStringInputTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Art4\JsonApiClient\Exception\InputException;
1212
use Art4\JsonApiClient\Input\RequestStringInput;
1313
use Art4\JsonApiClient\Tests\Fixtures\HelperTrait;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516

1617
class RequestStringInputTest extends TestCase
@@ -24,9 +25,7 @@ public function testGetAsObjectFromStringReturnsObject(): void
2425
$this->assertInstanceOf(\stdClass::class, $input->getAsObject());
2526
}
2627

27-
/**
28-
* @dataProvider jsonValuesProviderWithoutString
29-
*/
28+
#[DataProvider('jsonValuesProviderWithoutString')]
3029
public function testCreateWithoutStringThrowsException(mixed $input): void
3130
{
3231
$this->expectException(InputException::class);
@@ -36,9 +35,7 @@ public function testCreateWithoutStringThrowsException(mixed $input): void
3635
new RequestStringInput($input);
3736
}
3837

39-
/**
40-
* @dataProvider jsonValuesAsStringProviderWithoutObject
41-
*/
38+
#[DataProvider('jsonValuesAsStringProviderWithoutObject')]
4239
public function testGetAsObjectWithInvalidStringsThrowsException(string $input): void
4340
{
4441
$input = new RequestStringInput($input);

tests/Unit/Input/ResponseStringInputTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Art4\JsonApiClient\Exception\InputException;
1212
use Art4\JsonApiClient\Input\ResponseStringInput;
1313
use Art4\JsonApiClient\Tests\Fixtures\HelperTrait;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516

1617
class ResponseStringInputTest extends TestCase
@@ -24,9 +25,7 @@ public function testGetAsObjectFromStringReturnsObject(): void
2425
$this->assertInstanceOf(\stdClass::class, $input->getAsObject());
2526
}
2627

27-
/**
28-
* @dataProvider jsonValuesProviderWithoutString
29-
*/
28+
#[DataProvider('jsonValuesProviderWithoutString')]
3029
public function testCreateWithoutStringThrowsException(mixed $input): void
3130
{
3231
$this->expectException(InputException::class);
@@ -36,9 +35,7 @@ public function testCreateWithoutStringThrowsException(mixed $input): void
3635
new ResponseStringInput($input);
3736
}
3837

39-
/**
40-
* @dataProvider jsonValuesAsStringProviderWithoutObject
41-
*/
38+
#[DataProvider('jsonValuesAsStringProviderWithoutObject')]
4239
public function testGetAsObjectWithInvalidStringsThrowsException(string $input): void
4340
{
4441
$input = new ResponseStringInput($input);

tests/Unit/Manager/ErrorAbortManagerTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
class ErrorAbortManagerTest extends TestCase
1616
{
17-
/**
18-
* @test
19-
*/
2017
public function testCreateWithConstructorReturnsSelf(): void
2118
{
2219
$factory = $this->createMock(Factory::class);
@@ -25,9 +22,6 @@ public function testCreateWithConstructorReturnsSelf(): void
2522
$this->assertSame($factory, $manager->getFactory());
2623
}
2724

28-
/**
29-
* @test
30-
*/
3125
public function testGetParamReturnsDefault(): void
3226
{
3327
$factory = $this->createMock(Factory::class);

tests/Unit/V1/AttributesTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Art4\JsonApiClient\Exception\ValidationException;
1414
use Art4\JsonApiClient\Tests\Fixtures\HelperTrait;
1515
use Art4\JsonApiClient\V1\Attributes;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\TestCase;
1718

1819
class AttributesTest extends TestCase
@@ -80,9 +81,7 @@ public function testCreateWithObject(): void
8081
], $attributes->getKeys());
8182
}
8283

83-
/**
84-
* @dataProvider jsonValuesProviderWithoutObject
85-
*/
84+
#[DataProvider('jsonValuesProviderWithoutObject')]
8685
public function testCreateWithDataProvider(mixed $input): void
8786
{
8887
$this->expectException(ValidationException::class);
@@ -186,9 +185,6 @@ public function testCreateWithLinksPropertyThrowsException(): void
186185
);
187186
}
188187

189-
/**
190-
* @test
191-
*/
192188
public function testGetOnANonExistingKeyThrowsException(): void
193189
{
194190
$object = new \stdClass();

0 commit comments

Comments
 (0)