From 204f946b2c11846a759a9ed74fb43a314bf0f793 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Wed, 15 May 2024 12:41:16 +0200 Subject: [PATCH] Update tests to phpunit 10 attributes --- rector.php | 2 +- src/Commands/ProcessMollieWebhookTest.php | 18 +++---- .../HandleMollieWebhooksRequestTest.php | 19 ++++---- src/MollieWebhooksServiceProviderTest.php | 13 ++--- src/Orders/WebhookCallOrderHistoryTest.php | 14 +++--- .../WebhookCallPaymentHistoryTest.php | 14 +++--- ...atestMollieWebhookCallByResourceIdTest.php | 28 ++++------- .../SubscribeToMollieOrderRefundsTest.php | 23 ++++----- ...ubscribeToMollieOrderStatusChangesTest.php | 47 +++++++------------ .../SubscribeToMolliePaymentRefundsTest.php | 23 ++++----- ...scribeToMolliePaymentStatusChangesTest.php | 41 ++++++---------- src/Testing/PrefixedResourceIdTestCase.php | 36 +++++--------- src/WebhookPayloadFragmentTest.php | 14 +++--- 13 files changed, 111 insertions(+), 181 deletions(-) diff --git a/rector.php b/rector.php index a1ea6b2..cdafade 100644 --- a/rector.php +++ b/rector.php @@ -11,7 +11,7 @@ ]); $rectorConfig->sets([ - \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, + \Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_100, ]); $rectorConfig->skip([ diff --git a/src/Commands/ProcessMollieWebhookTest.php b/src/Commands/ProcessMollieWebhookTest.php index 79ce501..7ace53e 100644 --- a/src/Commands/ProcessMollieWebhookTest.php +++ b/src/Commands/ProcessMollieWebhookTest.php @@ -14,15 +14,15 @@ use Generator; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Event; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Spatie\WebhookClient\Models\WebhookCall; use function compact; final class ProcessMollieWebhookTest extends IntegrationTestCase { - /** - * @test - */ + #[Test] public function itShouldBeQueued(): void { $webhookCall = new WebhookCall([]); @@ -43,10 +43,8 @@ public static function invalidWebhookPayloads(): Generator ]; } - /** - * @test - * @dataProvider invalidWebhookPayloads - */ + #[Test] + #[DataProvider('invalidWebhookPayloads')] public function itFailsWhenTheWebhookPayloadIsInvalid(array $payload, Exception $exception): void { $this->expectExceptionObject($exception); @@ -69,10 +67,8 @@ public static function webhookPayloads(): Generator ]; } - /** - * @test - * @dataProvider webhookPayloads - */ + #[Test] + #[DataProvider('webhookPayloads')] public function itCanHandleIncomingWebhooks(callable $generatesResourceId, string $event): void { $resourceId = $generatesResourceId($this); diff --git a/src/Http/Requests/HandleMollieWebhooksRequestTest.php b/src/Http/Requests/HandleMollieWebhooksRequestTest.php index a64bd23..597908a 100644 --- a/src/Http/Requests/HandleMollieWebhooksRequestTest.php +++ b/src/Http/Requests/HandleMollieWebhooksRequestTest.php @@ -13,6 +13,9 @@ use Illuminate\Routing\Router; use Illuminate\Support\Facades\Bus; use Illuminate\Support\Str; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use function json_encode; @@ -23,9 +26,7 @@ final class HandleMollieWebhooksRequestTest extends IntegrationTestCase private const URI = '/mollie/webhooks/handle'; - /** - * @before - */ + #[Before] public function registerWebhooksHandlerRoute(): void { $this->afterApplicationCreated(function (): void { @@ -52,10 +53,8 @@ public static function invalidPayloads(): Generator ]; } - /** - * @test - * @dataProvider invalidPayloads - */ + #[Test] + #[DataProvider('invalidPayloads')] public function itCanHandleIncomingMollieWebhooksWithAnInvalidPayload(array $payload): void { $response = $this->post(self::URI, $payload); @@ -75,10 +74,8 @@ public static function validPayloads(): Generator ]; } - /** - * @test - * @dataProvider validPayloads - */ + #[Test] + #[DataProvider('validPayloads')] public function itCanHandleIncomingMollieWebhooks(array $payload): void { $response = $this->post(self::URI, $payload); diff --git a/src/MollieWebhooksServiceProviderTest.php b/src/MollieWebhooksServiceProviderTest.php index ac390c3..c78b1a2 100644 --- a/src/MollieWebhooksServiceProviderTest.php +++ b/src/MollieWebhooksServiceProviderTest.php @@ -12,14 +12,13 @@ use Craftzing\Laravel\MollieWebhooks\Testing\IntegrationTestCase; use Illuminate\Routing\Route; use Illuminate\Routing\Router; +use PHPUnit\Framework\Attributes\Test; final class MollieWebhooksServiceProviderTest extends IntegrationTestCase { private const URI = 'mollie/webhooks/handle'; - /** - * @test - */ + #[Test] public function itExtendsTheRouterToEnableRegisteringARouteToHandleIncomingWebhooks(): void { $router = $this->app[Router::class]; @@ -33,9 +32,7 @@ public function itExtendsTheRouterToEnableRegisteringARouteToHandleIncomingWebho $this->assertSame(self::URI, $route->uri); } - /** - * @test - */ + #[Test] public function itBindsADefaultImplementationForThePaymentHistory(): void { $paymentHistory = $this->app[PaymentHistory::class]; @@ -43,9 +40,7 @@ public function itBindsADefaultImplementationForThePaymentHistory(): void $this->assertInstanceOf(WebhookCallPaymentHistory::class, $paymentHistory); } - /** - * @test - */ + #[Test] public function itBindsADefaultImplementationForTheOrderHistory(): void { $orderHistory = $this->app[OrderHistory::class]; diff --git a/src/Orders/WebhookCallOrderHistoryTest.php b/src/Orders/WebhookCallOrderHistoryTest.php index 8e8150a..efb7d7e 100644 --- a/src/Orders/WebhookCallOrderHistoryTest.php +++ b/src/Orders/WebhookCallOrderHistoryTest.php @@ -9,6 +9,8 @@ use Craftzing\Laravel\MollieWebhooks\Testing\Doubles\FakeOrder; use Craftzing\Laravel\MollieWebhooks\Testing\IntegrationTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; final class WebhookCallOrderHistoryTest extends IntegrationTestCase { @@ -21,10 +23,8 @@ public static function orderWebhookCallHistory(): Generator } } - /** - * @test - * @dataProvider orderWebhookCallHistory - */ + #[Test] + #[DataProvider('orderWebhookCallHistory')] public function itCanCheckIfItHasALatestStatusForAnOrder( callable $resolveOrderStatus, bool $expectedToHaveSameLatestStatus @@ -48,10 +48,8 @@ public function itCanCheckIfItHasALatestStatusForAnOrder( } } - /** - * @test - * @dataProvider refundsWebhookCallHistory - */ + #[Test] + #[DataProvider('refundsWebhookCallHistory')] public function itCanCheckIfItHasARefundWithAStatusForAnOrder( callable $resolveRefundStatus, bool $expectedToHaveRefundWithStatus diff --git a/src/Payments/WebhookCallPaymentHistoryTest.php b/src/Payments/WebhookCallPaymentHistoryTest.php index d3e53cb..8c23be6 100644 --- a/src/Payments/WebhookCallPaymentHistoryTest.php +++ b/src/Payments/WebhookCallPaymentHistoryTest.php @@ -9,6 +9,8 @@ use Craftzing\Laravel\MollieWebhooks\Testing\Doubles\FakePayment; use Craftzing\Laravel\MollieWebhooks\Testing\IntegrationTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; final class WebhookCallPaymentHistoryTest extends IntegrationTestCase { @@ -21,10 +23,8 @@ public static function paymentWebhookCallHistory(): Generator } } - /** - * @test - * @dataProvider paymentWebhookCallHistory - */ + #[Test] + #[DataProvider('paymentWebhookCallHistory')] public function itCanCheckIfItHasALatestStatusForAPayment( callable $resolveOrderStatus, bool $expectedToHaveSameLatestStatus @@ -52,10 +52,8 @@ public function itCanCheckIfItHasALatestStatusForAPayment( } } - /** - * @test - * @dataProvider refundsWebhookCallHistory - */ + #[Test] + #[DataProvider('refundsWebhookCallHistory')] public function itCanCheckIfItHasATransferredRefundForAPayment( callable $resolveRefundStatus, bool $expectedToHaveRefundWithStatus diff --git a/src/Queries/LatestMollieWebhookCallByResourceIdTest.php b/src/Queries/LatestMollieWebhookCallByResourceIdTest.php index cf68d62..6eedb06 100644 --- a/src/Queries/LatestMollieWebhookCallByResourceIdTest.php +++ b/src/Queries/LatestMollieWebhookCallByResourceIdTest.php @@ -10,6 +10,8 @@ use Craftzing\Laravel\MollieWebhooks\WebhookPayloadFragment; use Generator; use Illuminate\Foundation\Testing\WithFaker; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Spatie\WebhookClient\Models\WebhookCall; final class LatestMollieWebhookCallByResourceIdTest extends IntegrationTestCase @@ -33,10 +35,8 @@ public static function noResults(): Generator ]; } - /** - * @test - * @dataProvider noResults - */ + #[Test] + #[DataProvider('noResults')] public function itCanHandleNoResults(callable $addWebhookCallHistory): void { $resourceId = $this->generatePaymentId(); @@ -50,9 +50,7 @@ public function itCanHandleNoResults(callable $addWebhookCallHistory): void $this->assertNull($result); } - /** - * @test - */ + #[Test] public function itCanFindTheLatestMollieWebhookCallByResourceId(): void { $resourceId = $this->generatePaymentId(); @@ -74,9 +72,7 @@ public function itCanFindTheLatestMollieWebhookCallByResourceId(): void $this->assertTrue($result->is($latestWebhookCall)); } - /** - * @test - */ + #[Test] public function itIgnoresFailedWebhookCalls(): void { $resourceId = $this->generatePaymentId(); @@ -120,10 +116,8 @@ function (ResourceId $resourceId): WebhookCall { ]; } - /** - * @test - * @dataProvider webhookCallByFragment - */ + #[Test] + #[DataProvider('webhookCallByFragment')] public function itCanBeFilteredByPayloadFragmentKeys(callable $resolveExpectedWebhookCallFromHistory): void { $resourceId = $this->generatePaymentId(); @@ -142,10 +136,8 @@ public function itCanBeFilteredByPayloadFragmentKeys(callable $resolveExpectedWe $this->assertTrue($result->is($expectedWebhookCall)); } - /** - * @test - * @dataProvider webhookCallByFragment - */ + #[Test] + #[DataProvider('webhookCallByFragment')] public function itCanBeFilteredByAPayloadFragmentValues(callable $resolveExpectedWebhookCallFromHistory): void { $resourceId = $this->generatePaymentId(); diff --git a/src/Subscribers/SubscribeToMollieOrderRefundsTest.php b/src/Subscribers/SubscribeToMollieOrderRefundsTest.php index d1e6479..e79d9eb 100644 --- a/src/Subscribers/SubscribeToMollieOrderRefundsTest.php +++ b/src/Subscribers/SubscribeToMollieOrderRefundsTest.php @@ -16,6 +16,9 @@ use Illuminate\Events\CallQueuedListener; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Spatie\WebhookClient\Models\WebhookCall; final class SubscribeToMollieOrderRefundsTest extends IntegrationTestCase @@ -24,9 +27,7 @@ final class SubscribeToMollieOrderRefundsTest extends IntegrationTestCase protected array $eventsToFake = FakeRefund::STATUS_EVENTS; - /** - * @before - */ + #[Before] public function fakeOrderHistory(): void { $this->afterApplicationCreated(function (): void { @@ -34,9 +35,7 @@ public function fakeOrderHistory(): void }); } - /** - * @test - */ + #[Test] public function itCanBeRegisteredAsAQueuedSubscriberForTheGenericOrderEvent(): void { $this->dontFakeEvents(); @@ -71,10 +70,8 @@ public static function orderHistory(): Generator ]; } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itDispatchesRefundStatusEventsWhenTheStatusIsNotInTheOrderHistory(callable $resolveRefunds): void { /** @var \Craftzing\Laravel\MollieWebhooks\Testing\Doubles\FakeRefund[] $refunds */ @@ -100,10 +97,8 @@ public function itDispatchesRefundStatusEventsWhenTheStatusIsNotInTheOrderHistor } } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itDoesNotDispatchRefundStatusEventsWhenTheStatusExistsInTheOrderHistory( callable $resolveRefunds ): void { diff --git a/src/Subscribers/SubscribeToMollieOrderStatusChangesTest.php b/src/Subscribers/SubscribeToMollieOrderStatusChangesTest.php index b61ed41..2f9a153 100644 --- a/src/Subscribers/SubscribeToMollieOrderStatusChangesTest.php +++ b/src/Subscribers/SubscribeToMollieOrderStatusChangesTest.php @@ -22,15 +22,16 @@ use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; use Mollie\Api\Types\OrderStatus; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Spatie\WebhookClient\Models\WebhookCall; final class SubscribeToMollieOrderStatusChangesTest extends IntegrationTestCase { private FakeOrderHistory $fakeOrderHistory; - /** - * @before - */ + #[Before] public function fakePaymentHistory(): void { $this->afterApplicationCreated(function (): void { @@ -38,9 +39,7 @@ public function fakePaymentHistory(): void }); } - /** - * @test - */ + #[Test] public function itCanBeRegisteredAsAQueuedSubscriberForTheGenericOrderEvent(): void { $this->dontFakeEvents(); @@ -70,10 +69,8 @@ function (FakeOrderHistory $fakeOrderHistory) use ($orderStatus): string { } } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToPaid(callable $addOrderHistory): void { $paid = OrderStatus::STATUS_PAID; @@ -97,10 +94,8 @@ public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToPaid(call } } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToExpired(callable $addOrderHistory): void { $expired = OrderStatus::STATUS_EXPIRED; @@ -124,10 +119,8 @@ public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToExpired(c } } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToAuthorized(callable $addOrderHistory): void { $authorized = OrderStatus::STATUS_AUTHORIZED; @@ -151,10 +144,8 @@ public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToAuthorize } } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToCanceled(callable $addOrderHistory): void { $canceled = OrderStatus::STATUS_CANCELED; @@ -178,10 +169,8 @@ public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToCanceled( } } - /** - * @test - * @dataProvider orderHistory - */ + #[Test] + #[DataProvider('orderHistory')] public function itCanHandleWebhookCallsIndicatingAnOrderStatusChangedToCompleted(callable $addOrderHistory): void { $completed = OrderStatus::STATUS_COMPLETED; @@ -225,10 +214,8 @@ public static function statusesThatDontFireEvents(): Generator ]; } - /** - * @test - * @dataProvider statusesThatDontFireEvents - */ + #[Test] + #[DataProvider('statusesThatDontFireEvents')] public function itCanHandleWebhookCallsWithoutAnOrderStatusThatWeListenTo(string $status): void { $webhookCall = $this->webhookCallIndicatingOrderStatusChangedTo($status); diff --git a/src/Subscribers/SubscribeToMolliePaymentRefundsTest.php b/src/Subscribers/SubscribeToMolliePaymentRefundsTest.php index 6dcbf3b..7b353f7 100644 --- a/src/Subscribers/SubscribeToMolliePaymentRefundsTest.php +++ b/src/Subscribers/SubscribeToMolliePaymentRefundsTest.php @@ -16,6 +16,9 @@ use Illuminate\Events\CallQueuedListener; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Spatie\WebhookClient\Models\WebhookCall; final class SubscribeToMolliePaymentRefundsTest extends IntegrationTestCase @@ -24,9 +27,7 @@ final class SubscribeToMolliePaymentRefundsTest extends IntegrationTestCase protected array $eventsToFake = FakeRefund::STATUS_EVENTS; - /** - * @before - */ + #[Before] public function fakePaymentHistory(): void { $this->afterApplicationCreated(function (): void { @@ -34,9 +35,7 @@ public function fakePaymentHistory(): void }); } - /** - * @test - */ + #[Test] public function itCanBeRegisteredAsAQueuedSubscriberForTheGenericPaymentEvent(): void { $this->dontFakeEvents(); @@ -71,10 +70,8 @@ public static function paymentHistory(): Generator ]; } - /** - * @test - * @dataProvider paymentHistory - */ + #[Test] + #[DataProvider('paymentHistory')] public function itDispatchesRefundStatusEventsWhenTheStatusIsNotInThePaymentHistory(callable $resolveRefunds): void { /** @var \Craftzing\Laravel\MollieWebhooks\Testing\Doubles\FakeRefund[] $refunds */ @@ -100,10 +97,8 @@ public function itDispatchesRefundStatusEventsWhenTheStatusIsNotInThePaymentHist } } - /** - * @test - * @dataProvider paymentHistory - */ + #[Test] + #[DataProvider('paymentHistory')] public function itDoesNotDispatchRefundStatusEventsWhenTheStatusExistsInThePaymentHistory( callable $resolveRefunds ): void { diff --git a/src/Subscribers/SubscribeToMolliePaymentStatusChangesTest.php b/src/Subscribers/SubscribeToMolliePaymentStatusChangesTest.php index e198cdb..bb7d917 100644 --- a/src/Subscribers/SubscribeToMolliePaymentStatusChangesTest.php +++ b/src/Subscribers/SubscribeToMolliePaymentStatusChangesTest.php @@ -21,15 +21,16 @@ use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; use Mollie\Api\Types\PaymentStatus; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Spatie\WebhookClient\Models\WebhookCall; final class SubscribeToMolliePaymentStatusChangesTest extends IntegrationTestCase { private FakePaymentHistory $fakePaymentHistory; - /** - * @before - */ + #[Before] public function fakePaymentHistory(): void { $this->afterApplicationCreated(function (): void { @@ -37,9 +38,7 @@ public function fakePaymentHistory(): void }); } - /** - * @test - */ + #[Test] public function itCanBeRegisteredAsAQueuedSubscriberForTheGenericPaymentEvent(): void { $this->dontFakeEvents(); @@ -69,10 +68,8 @@ function (FakePaymentHistory $fakePaymentHistory) use ($paymentStatus): string { } } - /** - * @test - * @dataProvider paymentHistory - */ + #[Test] + #[DataProvider('paymentHistory')] public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToPaid(callable $addPaymentHistory): void { $paid = PaymentStatus::STATUS_PAID; @@ -96,10 +93,8 @@ public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToPaid(cal } } - /** - * @test - * @dataProvider paymentHistory - */ + #[Test] + #[DataProvider('paymentHistory')] public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToExpired(callable $addPaymentHistory): void { $expired = PaymentStatus::STATUS_EXPIRED; @@ -123,10 +118,8 @@ public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToExpired( } } - /** - * @test - * @dataProvider paymentHistory - */ + #[Test] + #[DataProvider('paymentHistory')] public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToFailed(callable $addPaymentHistory): void { $failed = PaymentStatus::STATUS_FAILED; @@ -150,10 +143,8 @@ public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToFailed(c } } - /** - * @test - * @dataProvider paymentHistory - */ + #[Test] + #[DataProvider('paymentHistory')] public function itCanHandleWebhookCallsIndicatingAPaymentStatusChangedToCanceled(callable $addPaymentHistory): void { $canceled = PaymentStatus::STATUS_CANCELED; @@ -201,10 +192,8 @@ public static function statusesThatDontFireEvents(): Generator ]; } - /** - * @test - * @dataProvider statusesThatDontFireEvents - */ + #[Test] + #[DataProvider('statusesThatDontFireEvents')] public function itCanHandleWebhookCallsWithoutAPaymentStatusThatWeListenTo(string $status): void { $webhookCall = $this->webhookCallIndicatingPaymentStatusChangedTo($status); diff --git a/src/Testing/PrefixedResourceIdTestCase.php b/src/Testing/PrefixedResourceIdTestCase.php index 3583172..4f1ce0b 100644 --- a/src/Testing/PrefixedResourceIdTestCase.php +++ b/src/Testing/PrefixedResourceIdTestCase.php @@ -7,6 +7,8 @@ use Craftzing\Laravel\MollieWebhooks\ResourceId; use Generator; use Illuminate\Support\Str; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function call_user_func; @@ -29,10 +31,8 @@ public static function invalidMollieResourceIds(): Generator yield 'Value has an invalid prefix' => ['pa_' . Str::random(8)]; } - /** - * @test - * @dataProvider invalidMollieResourceIds - */ + #[Test] + #[DataProvider('invalidMollieResourceIds')] public function itCannotBeConstructedFromAnInvalidMollieResourceIdString(string $value): void { $this->expectExceptionObject( @@ -48,10 +48,8 @@ public static function validMollieResourceIds(): Generator yield 'Long identifier' => [fn (self $test): string => $test::expectedPrefix() . Str::random(8)]; } - /** - * @test - * @dataProvider validMollieResourceIds - */ + #[Test] + #[DataProvider('validMollieResourceIds')] public function itCanBeConstructedFromAValidMollieResourceIdString(callable $resolveValue): void { $value = $resolveValue($this); @@ -61,10 +59,8 @@ public function itCanBeConstructedFromAValidMollieResourceIdString(callable $res $this->assertInstanceOf(ResourceId::class, $resourceId); } - /** - * @test - * @dataProvider validMollieResourceIds - */ + #[Test] + #[DataProvider('validMollieResourceIds')] public function itCanBeCastedToAString(callable $resolveValue): void { $value = $resolveValue($this); @@ -74,10 +70,8 @@ public function itCanBeCastedToAString(callable $resolveValue): void $this->assertSame($value, (string) $resourceId); } - /** - * @test - * @dataProvider validMollieResourceIds - */ + #[Test] + #[DataProvider('validMollieResourceIds')] public function itCanReturnItsValue(callable $resolveValue): void { $value = $resolveValue($this); @@ -87,10 +81,8 @@ public function itCanReturnItsValue(callable $resolveValue): void $this->assertSame($value, $resourceId->value()); } - /** - * @test - * @dataProvider validMollieResourceIds - */ + #[Test] + #[DataProvider('validMollieResourceIds')] public function itCanBeSerialized(callable $resolveValue): void { $value = $resolveValue($this); @@ -102,9 +94,7 @@ public function itCanBeSerialized(callable $resolveValue): void $this->assertEquals($resourceId, unserialize($serializedResourceId, [$this::resourceIdClass()])); } - /** - * @test - */ + #[Test] public function itCanBeUsedAsAResourceId(): void { $resourceId = $this::resourceIdClass()::fromString($this::expectedPrefix() . Str::random(8)); diff --git a/src/WebhookPayloadFragmentTest.php b/src/WebhookPayloadFragmentTest.php index d2ccb94..281daeb 100644 --- a/src/WebhookPayloadFragmentTest.php +++ b/src/WebhookPayloadFragmentTest.php @@ -5,6 +5,8 @@ namespace Craftzing\Laravel\MollieWebhooks; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function array_filter; @@ -19,10 +21,8 @@ public static function keys(): Generator yield 'Multiple keys' => ['foo', 'bar', 'baz']; } - /** - * @test - * @dataProvider keys - */ + #[Test] + #[DataProvider('keys')] public function itCanBeConstructedFromKeys(string ...$keys): void { $keys = array_filter($keys); @@ -55,10 +55,8 @@ public static function values(): Generator ]; } - /** - * @test - * @dataProvider values - */ + #[Test] + #[DataProvider('values')] public function itCanBeConstructedFromValues(array $values): void { $values = array_filter($values);