diff --git a/rector.php b/rector.php index 913f3c64..2d38fe63 100644 --- a/rector.php +++ b/rector.php @@ -6,4 +6,8 @@ return RectorConfig::configure() ->withRules([ CoversAnnotationWithValueToAttributeRector::class, - ]); + ]) + ->withImportNames( + removeUnusedImports: true, + importDocBlockNames: true, + ); diff --git a/tests/Unit/DataTransferObjects/AuthTokensDTOTest.php b/tests/Unit/DataTransferObjects/AuthTokensDTOTest.php index 7c1fabb9..33e8c6af 100644 --- a/tests/Unit/DataTransferObjects/AuthTokensDTOTest.php +++ b/tests/Unit/DataTransferObjects/AuthTokensDTOTest.php @@ -5,11 +5,12 @@ use Carbon\CarbonImmutable; use Illuminate\Support\Str; use Jasara\AmznSPA\DataTransferObjects\AuthTokensDTO; +use Jasara\AmznSPA\DataTransferObjects\Casts\CarbonFromSecondsCaster; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(AuthTokensDTO::class)] -#[CoversClass(\Jasara\AmznSPA\DataTransferObjects\Casts\CarbonFromSecondsCaster::class)] +#[CoversClass(CarbonFromSecondsCaster::class)] class AuthTokensDTOTest extends UnitTestCase { public function testSetupDTO() diff --git a/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemLengthDimensionSchemaTest.php b/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemLengthDimensionSchemaTest.php index ccca793f..3cf9d20d 100644 --- a/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemLengthDimensionSchemaTest.php +++ b/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemLengthDimensionSchemaTest.php @@ -4,11 +4,10 @@ use Jasara\AmznSPA\DataTransferObjects\Schemas\CatalogItems\ItemLengthDimensionSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PhpUnitsOfMeasure\PhysicalQuantity\Length; -/** - * @covers \Jasara\AmznSPA\DataTransferObjects\Schemas\CatalogItems\ItemLengthDimensionSchema - */ +#[CoversClass(ItemLengthDimensionSchema::class)] class ItemLengthDimensionSchemaTest extends UnitTestCase { public function testAsUom() diff --git a/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemMassDimensionSchemaTest.php b/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemMassDimensionSchemaTest.php index cf611118..b595c73a 100644 --- a/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemMassDimensionSchemaTest.php +++ b/tests/Unit/DataTransferObjects/Schemas/CatalogItems/ItemMassDimensionSchemaTest.php @@ -4,11 +4,10 @@ use Jasara\AmznSPA\DataTransferObjects\Schemas\CatalogItems\ItemMassDimensionSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PhpUnitsOfMeasure\PhysicalQuantity\Mass; -/** - * @covers \Jasara\AmznSPA\DataTransferObjects\Schemas\CatalogItems\ItemMassDimensionSchema - */ +#[CoversClass(ItemMassDimensionSchema::class)] class ItemMassDimensionSchemaTest extends UnitTestCase { public function testAsUom() diff --git a/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/CreateInboundShipmentPlanRequestTest.php b/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/CreateInboundShipmentPlanRequestTest.php index 2fd6129d..edf98537 100644 --- a/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/CreateInboundShipmentPlanRequestTest.php +++ b/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/CreateInboundShipmentPlanRequestTest.php @@ -2,11 +2,11 @@ namespace Jasara\AmznSPA\Tests\Unit\DataTransferObjects\Schemas\FulfillmentInbound; +use Jasara\AmznSPA\DataTransferObjects\Requests\BaseRequest; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers Jasara\AmznSPA\DataTransferObjects\Requests\BaseRequest - */ +#[CoversClass(BaseRequest::class)] class CreateInboundShipmentPlanRequestTest extends UnitTestCase { public function testToArrayObject() diff --git a/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/InboundShipmentRequestTest.php b/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/InboundShipmentRequestTest.php index 1bce3d08..d3786900 100644 --- a/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/InboundShipmentRequestTest.php +++ b/tests/Unit/DataTransferObjects/Schemas/FulfillmentInbound/InboundShipmentRequestTest.php @@ -3,12 +3,12 @@ namespace Jasara\AmznSPA\Tests\Unit\DataTransferObjects\Schemas\FulfillmentInbound; use Illuminate\Support\Str; +use Jasara\AmznSPA\DataTransferObjects\Requests\BaseRequest; use Jasara\AmznSPA\DataTransferObjects\Requests\FulfillmentInbound\InboundShipmentRequest; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers Jasara\AmznSPA\DataTransferObjects\Requests\BaseRequest - */ +#[CoversClass(BaseRequest::class)] class InboundShipmentRequestTest extends UnitTestCase { public function testToArrayObject() diff --git a/tests/Unit/DataTransferObjects/Schemas/MerchantFulfillment/PackageDimensionsSchemaTest.php b/tests/Unit/DataTransferObjects/Schemas/MerchantFulfillment/PackageDimensionsSchemaTest.php index d552b85f..c9ce5d38 100644 --- a/tests/Unit/DataTransferObjects/Schemas/MerchantFulfillment/PackageDimensionsSchemaTest.php +++ b/tests/Unit/DataTransferObjects/Schemas/MerchantFulfillment/PackageDimensionsSchemaTest.php @@ -4,11 +4,10 @@ use Jasara\AmznSPA\DataTransferObjects\Schemas\MerchantFulfillment\PackageDimensionsSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PhpUnitsOfMeasure\PhysicalQuantity\Length; -/** - * @covers \Jasara\AmznSPA\DataTransferObjects\Schemas\MerchantFulfillment\PackageDimensionsSchema - */ +#[CoversClass(PackageDimensionsSchema::class)] class PackageDimensionsSchemaTest extends UnitTestCase { public function testAsUom() diff --git a/tests/Unit/DataTransferObjects/Schemas/WeightSchemaTest.php b/tests/Unit/DataTransferObjects/Schemas/WeightSchemaTest.php index 9bd132d2..8683afd5 100644 --- a/tests/Unit/DataTransferObjects/Schemas/WeightSchemaTest.php +++ b/tests/Unit/DataTransferObjects/Schemas/WeightSchemaTest.php @@ -4,11 +4,10 @@ use Jasara\AmznSPA\DataTransferObjects\Schemas\WeightSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PhpUnitsOfMeasure\PhysicalQuantity\Mass; -/** - * @covers \Jasara\AmznSPA\DataTransferObjects\Schemas\WeightSchema - */ +#[CoversClass(WeightSchema::class)] class WeightSchemaTest extends UnitTestCase { public function testAsUom() diff --git a/tests/Unit/Resources/AuthorizationResourceTest.php b/tests/Unit/Resources/AuthorizationResourceTest.php index 700dd2f6..20ca8aeb 100644 --- a/tests/Unit/Resources/AuthorizationResourceTest.php +++ b/tests/Unit/Resources/AuthorizationResourceTest.php @@ -8,11 +8,10 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\FulfillmentInbound\GetAuthorizationCodeResponse; use Jasara\AmznSPA\Exceptions\GrantlessAuthenticationException; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\AuthorizationResource - * @covers \Jasara\AmznSPA\Exceptions\GrantlessAuthenticationException - */ +#[CoversClass(\Jasara\AmznSPA\Resources\AuthorizationResource::class)] +#[CoversClass(GrantlessAuthenticationException::class)] class AuthorizationResourceTest extends UnitTestCase { public function testGetAuthorizationCodeFromMwsToken() @@ -31,7 +30,7 @@ public function testGetAuthorizationCodeFromMwsToken() $http->assertSent(function (Request $request) use ($seller_id, $developer_id, $mws_auth_token) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/authorization/v1/authorizationCode?sellingPartnerId=' . $seller_id . '&developerId=' . $developer_id . '&mwsAuthToken=' . $mws_auth_token, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/authorization/v1/authorizationCode?sellingPartnerId='.$seller_id.'&developerId='.$developer_id.'&mwsAuthToken='.$mws_auth_token, urldecode($request->url())); return true; }); @@ -39,7 +38,7 @@ public function testGetAuthorizationCodeFromMwsToken() public function testGetAuthorizationCodeNoAuthorizationExistsError() { - $this->expectException(GrantlessAuthenticationException ::class); + $this->expectException(GrantlessAuthenticationException::class); list($config, $http) = $this->setupConfigWithFakeHttp('authorization/no-authorization-exists-error', 400); @@ -53,7 +52,7 @@ public function testGetAuthorizationCodeNoAuthorizationExistsError() $http->assertSent(function (Request $request) use ($seller_id, $developer_id, $mws_auth_token) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/authorization/v1/authorizationCode?sellingPartnerId=' . $seller_id . '&developerId=' . $developer_id . '&mwsAuthToken=' . $mws_auth_token, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/authorization/v1/authorizationCode?sellingPartnerId='.$seller_id.'&developerId='.$developer_id.'&mwsAuthToken='.$mws_auth_token, urldecode($request->url())); return true; }); @@ -75,7 +74,7 @@ public function testGetAuthorizationCodeNoAuthorizationFoundError() $http->assertSent(function (Request $request) use ($seller_id, $developer_id, $mws_auth_token) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/authorization/v1/authorizationCode?sellingPartnerId=' . $seller_id . '&developerId=' . $developer_id . '&mwsAuthToken=' . $mws_auth_token, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/authorization/v1/authorizationCode?sellingPartnerId='.$seller_id.'&developerId='.$developer_id.'&mwsAuthToken='.$mws_auth_token, urldecode($request->url())); return true; }); diff --git a/tests/Unit/Resources/CatalogItems/CatalogItems20201201ResourceTest.php b/tests/Unit/Resources/CatalogItems/CatalogItems20201201ResourceTest.php index 9ec5e242..7bdb57ed 100644 --- a/tests/Unit/Resources/CatalogItems/CatalogItems20201201ResourceTest.php +++ b/tests/Unit/Resources/CatalogItems/CatalogItems20201201ResourceTest.php @@ -8,10 +8,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\CatalogItems\v20201201\GetCatalogItemResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\CatalogItems\v20201201\ItemSearchResults; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\CatalogItems\CatalogItems20201201Resource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\CatalogItems\CatalogItems20201201Resource::class)] class CatalogItems20201201ResourceTest extends UnitTestCase { public function testSearchCatalogItems() @@ -35,7 +34,7 @@ classification_ids: ['ID'], $http->assertSent(function (Request $request) use ($keyword) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items?keywords=' . $keyword . '&marketplaceIds=ATVPDKIKX0DER&includedData=images&brandNames=BRAND&classificationIds=ID', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items?keywords='.$keyword.'&marketplaceIds=ATVPDKIKX0DER&includedData=images&brandNames=BRAND&classificationIds=ID', $request->url()); return true; }); @@ -60,13 +59,13 @@ public function testGetCatalogItem() $http->assertSent(function (Request $request) use ($asin) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/' . $asin . '?marketplaceIds=ATVPDKIKX0DER&includedData=images', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/'.$asin.'?marketplaceIds=ATVPDKIKX0DER&includedData=images', $request->url()); return true; }); } - public function testGetCatalogItem_Issue10_404() + public function testGetCatalogItemIssue10404() { list($config, $http) = $this->setupConfigWithFakeHttp('catalog-items/v20201201/issues/issue-10-404-not-found'); @@ -85,7 +84,7 @@ public function testGetCatalogItem_Issue10_404() $http->assertSent(function (Request $request) use ($asin) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/' . $asin . '?marketplaceIds=ATVPDKIKX0DER&includedData=images', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/'.$asin.'?marketplaceIds=ATVPDKIKX0DER&includedData=images', $request->url()); return true; }); diff --git a/tests/Unit/Resources/CatalogItems/CatalogItems20220401ResourceTest.php b/tests/Unit/Resources/CatalogItems/CatalogItems20220401ResourceTest.php index e931b9ec..f9d39cbe 100644 --- a/tests/Unit/Resources/CatalogItems/CatalogItems20220401ResourceTest.php +++ b/tests/Unit/Resources/CatalogItems/CatalogItems20220401ResourceTest.php @@ -9,10 +9,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\CatalogItems\v20220401\ItemSearchResults; use Jasara\AmznSPA\Enums\CatalogItems\ItemIdentifierTypes; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\CatalogItems\CatalogItems20220401Resource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\CatalogItems\CatalogItems20220401Resource::class)] class CatalogItems20220401ResourceTest extends UnitTestCase { public function testSearchCatalogItems() @@ -63,7 +62,7 @@ public function testGetCatalogItem() $this->assertRequestSent( $http, - 'https://sellingpartnerapi-na.amazon.com/catalog/2022-04-01/items/' . $asin, + 'https://sellingpartnerapi-na.amazon.com/catalog/2022-04-01/items/'.$asin, compact('marketplace_ids', 'included_data'), ); } diff --git a/tests/Unit/Resources/FbaInboundEligibilityResourceTest.php b/tests/Unit/Resources/FbaInboundEligibilityResourceTest.php index 7f84c8cf..632068f3 100644 --- a/tests/Unit/Resources/FbaInboundEligibilityResourceTest.php +++ b/tests/Unit/Resources/FbaInboundEligibilityResourceTest.php @@ -6,10 +6,9 @@ use Jasara\AmznSPA\AmznSPA; use Jasara\AmznSPA\DataTransferObjects\Responses\FbaInboundEligibility\GetItemEligibilityPreviewResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\FbaInboundEligibilityResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\FbaInboundEligibilityResource::class)] class FbaInboundEligibilityResourceTest extends UnitTestCase { public function testGetItemEligibilityPreview() diff --git a/tests/Unit/Resources/FbaInventoryResourceTest.php b/tests/Unit/Resources/FbaInventoryResourceTest.php index 22c9c6c9..1a00d0d4 100644 --- a/tests/Unit/Resources/FbaInventoryResourceTest.php +++ b/tests/Unit/Resources/FbaInventoryResourceTest.php @@ -8,10 +8,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\CatalogItems\v20201201\GetCatalogItemResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\FbaInventory\GetInventorySummariesResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\FbaInventoryResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\FbaInventoryResource::class)] class FbaInventoryResourceTest extends UnitTestCase { public function testGetInventorySummaries() @@ -36,7 +35,7 @@ public function testGetInventorySummaries() $http->assertSent(function (Request $request) use ($sku) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inventory/v1/summaries?granularityType=Marketplace&granularityId=ATVPDKIKX0DER&sellerSkus=' . $sku . '&marketplaceIds=ATVPDKIKX0DER', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inventory/v1/summaries?granularityType=Marketplace&granularityId=ATVPDKIKX0DER&sellerSkus='.$sku.'&marketplaceIds=ATVPDKIKX0DER', $request->url()); return true; }); @@ -61,7 +60,7 @@ public function testGetCatalogItem() $http->assertSent(function (Request $request) use ($asin) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/' . $asin . '?marketplaceIds=ATVPDKIKX0DER&includedData=images', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/catalog/2020-12-01/items/'.$asin.'?marketplaceIds=ATVPDKIKX0DER&includedData=images', $request->url()); return true; }); diff --git a/tests/Unit/Resources/FeedsResourceTest.php b/tests/Unit/Resources/FeedsResourceTest.php index 6290b564..8a5f5e6d 100644 --- a/tests/Unit/Resources/FeedsResourceTest.php +++ b/tests/Unit/Resources/FeedsResourceTest.php @@ -14,10 +14,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\Feeds\GetFeedResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\Feeds\GetFeedsResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\FeedsResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\FeedsResource::class)] class FeedsResourceTest extends UnitTestCase { public function testGetFeeds() @@ -99,7 +98,7 @@ public function testGetFeed() $http->assertSent(function (Request $request) use ($feed_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/feeds/' . $feed_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/feeds/'.$feed_id, $request->url()); return true; }); @@ -119,7 +118,7 @@ public function testCancelFeed() $http->assertSent(function (Request $request) use ($feed_id) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/feeds/' . $feed_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/feeds/'.$feed_id, $request->url()); return true; }); @@ -163,7 +162,7 @@ public function testGetFeedDocument() $http->assertSent(function (Request $request) use ($feed_document_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/documents/' . $feed_document_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/feeds/2021-06-30/documents/'.$feed_document_id, $request->url()); return true; }); diff --git a/tests/Unit/Resources/FulfillmentInboundResourceTest.php b/tests/Unit/Resources/FulfillmentInboundResourceTest.php index 5647024a..e404107b 100644 --- a/tests/Unit/Resources/FulfillmentInboundResourceTest.php +++ b/tests/Unit/Resources/FulfillmentInboundResourceTest.php @@ -24,10 +24,10 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\FulfillmentInbound\PutTransportDetailsResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\FulfillmentInbound\VoidTransportResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; -/** - * @covers \Jasara\AmznSPA\Resources\FulfillmentInboundResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\FulfillmentInboundResource::class)] class FulfillmentInboundResourceTest extends UnitTestCase { public function testGetInboundGuidance() @@ -44,7 +44,7 @@ public function testGetInboundGuidance() $http->assertSent(function (Request $request) use ($sku) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/itemsGuidance?MarketplaceId=ATVPDKIKX0DER&SellerSKUList=' . $sku, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/itemsGuidance?MarketplaceId=ATVPDKIKX0DER&SellerSKUList='.$sku, urldecode($request->url())); return true; }); @@ -101,7 +101,7 @@ public function testUpdateInboundShipment() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('PUT', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id, urldecode($request->url())); return true; }); @@ -139,7 +139,7 @@ public function testCreateInboundShipment() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id, urldecode($request->url())); return true; }); @@ -159,7 +159,7 @@ public function testGetPreorderInfo() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/preorder?MarketplaceId=ATVPDKIKX0DER', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/preorder?MarketplaceId=ATVPDKIKX0DER', urldecode($request->url())); return true; }); @@ -179,7 +179,7 @@ public function testConfirmPreorder() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('PUT', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/preorder/confirm', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/preorder/confirm', urldecode($request->url())); $this->assertEquals(CarbonImmutable::now()->toDateString(), $request->data()['NeedByDate']); return true; @@ -200,7 +200,7 @@ public function testGetPrepInstructions() $http->assertSent(function (Request $request) use ($sku) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/prepInstructions?ShipToCountryCode=US&SellerSKUList=' . $sku, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/prepInstructions?ShipToCountryCode=US&SellerSKUList='.$sku, urldecode($request->url())); return true; }); @@ -240,18 +240,16 @@ public function testGetTransportDetails() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport', urldecode($request->url())); return true; }); } - /** - * @dataProvider transportDetailsDataProvider - */ - public function testGetTransportDetails_Issue(string $stub) + #[DataProvider('transportDetailsDataProvider')] + public function testGetTransportDetailsIssue(string $stub) { - [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/' . $stub); + [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/'.$stub); $shipment_id = Str::random(); @@ -263,13 +261,13 @@ public function testGetTransportDetails_Issue(string $stub) $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport', urldecode($request->url())); return true; }); } - public function testGetTransportDetails_Issue_ContactPropertyIsNull() + public function testGetTransportDetailsIssueContactPropertyIsNull() { [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/issue-56-contact-null'); @@ -283,7 +281,7 @@ public function testGetTransportDetails_Issue_ContactPropertyIsNull() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport', urldecode($request->url())); return true; }); @@ -307,7 +305,7 @@ public function testPutTransportDetails() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('PUT', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport', urldecode($request->url())); return true; }); @@ -327,7 +325,7 @@ public function testVoidTransport() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport/void', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport/void', urldecode($request->url())); return true; }); @@ -347,7 +345,7 @@ public function testEstimateTransport() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport/estimate', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport/estimate', urldecode($request->url())); return true; }); @@ -367,7 +365,7 @@ public function testConfirmTransport() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/transport/confirm', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/transport/confirm', urldecode($request->url())); return true; }); @@ -387,7 +385,7 @@ public function testGetLabels() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/labels?PageType=PackageLabel_Letter_2&LabelType=BARCODE_2D', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/labels?PageType=PackageLabel_Letter_2&LabelType=BARCODE_2D', urldecode($request->url())); return true; }); @@ -408,7 +406,7 @@ public function testGetBillOfLading() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/billOfLading', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/billOfLading', urldecode($request->url())); return true; }); @@ -455,18 +453,16 @@ public function testGetShipmentItemsByShipmentId() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/items?MarketplaceId=ATVPDKIKX0DER', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/items?MarketplaceId=ATVPDKIKX0DER', urldecode($request->url())); return true; }); } - /** - * @dataProvider shipmentItemsDataProvider - */ - public function testGetShipmentItemsByShipmentId_Issues($stub) + #[DataProvider('shipmentItemsDataProvider')] + public function testGetShipmentItemsByShipmentIdIssues($stub) { - [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/' . $stub); + [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/'.$stub); $shipment_id = Str::random(); @@ -481,7 +477,7 @@ public function testGetShipmentItemsByShipmentId_Issues($stub) $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/' . $shipment_id . '/items?MarketplaceId=ATVPDKIKX0DER', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipments/'.$shipment_id.'/items?MarketplaceId=ATVPDKIKX0DER', urldecode($request->url())); return true; }); @@ -507,13 +503,13 @@ public function testGetShipmentItems() $http->assertSent(function (Request $request) use ($last_updated_after, $last_updated_before) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipmentItems?MarketplaceId=ATVPDKIKX0DER&QueryType=DATE_RANGE&LastUpdatedAfter=' . $last_updated_after->tz('UTC')->format('Y-m-d\TH:i:s\Z') . '&LastUpdatedBefore=' . $last_updated_before->tz('UTC')->format('Y-m-d\TH:i:s\Z'), urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/fba/inbound/v0/shipmentItems?MarketplaceId=ATVPDKIKX0DER&QueryType=DATE_RANGE&LastUpdatedAfter='.$last_updated_after->tz('UTC')->format('Y-m-d\TH:i:s\Z').'&LastUpdatedBefore='.$last_updated_before->tz('UTC')->format('Y-m-d\TH:i:s\Z'), urldecode($request->url())); return true; }); } - public function testGetShipments_Issues() + public function testGetShipmentsIssues() { [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/issue-48-city-null'); @@ -535,7 +531,7 @@ public function testGetShipments_Issues() }); } - public function testGetShipments_Issues_InvalidShipmentStatus() + public function testGetShipmentsIssuesInvalidShipmentStatus() { [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/issue-55-invalid-shipment-status'); @@ -557,7 +553,7 @@ public function testGetShipments_Issues_InvalidShipmentStatus() }); } - public function testGetShipments_Issues_MissingShipFromAddress() + public function testGetShipmentsIssuesMissingShipFromAddress() { [$config, $http] = $this->setupConfigWithFakeHttp('fulfillment-inbound/issues/issue-65-ship-from-address-empty'); diff --git a/tests/Unit/Resources/FulfillmentOutboundResourceTest.php b/tests/Unit/Resources/FulfillmentOutboundResourceTest.php index 99dc021c..57fb1b8b 100644 --- a/tests/Unit/Resources/FulfillmentOutboundResourceTest.php +++ b/tests/Unit/Resources/FulfillmentOutboundResourceTest.php @@ -23,11 +23,10 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\FulfillmentOutbound\ListReturnReasonCodesResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\FulfillmentOutbound\UpdateFulfillmentOrderResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\FulfillmentOutboundResource - * @covers \Jasara\AmznSPA\DataTransferObjects\Requests\BaseRequest - */ +#[CoversClass(\Jasara\AmznSPA\Resources\FulfillmentOutboundResource::class)] +#[CoversClass(\Jasara\AmznSPA\DataTransferObjects\Requests\BaseRequest::class)] class FulfillmentOutboundResourceTest extends UnitTestCase { public function testGetFulfillmentPreview() diff --git a/tests/Unit/Resources/ListingsItemsResourceTest.php b/tests/Unit/Resources/ListingsItemsResourceTest.php index a9a3d9cc..df14f79b 100644 --- a/tests/Unit/Resources/ListingsItemsResourceTest.php +++ b/tests/Unit/Resources/ListingsItemsResourceTest.php @@ -13,10 +13,9 @@ use Jasara\AmznSPA\DataTransferObjects\Schemas\ListingsItems\AttributeSchema; use Jasara\AmznSPA\DataTransferObjects\Schemas\ListingsItems\AttributesListSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\ListingsItemsResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\ListingsItemsResource::class)] class ListingsItemsResourceTest extends UnitTestCase { public function testGetListingsItem() @@ -41,7 +40,7 @@ public function testGetListingsItem() $http->assertSent(function (Request $request) use ($seller_id, $sku) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/' . $seller_id . '/' . $sku . '?marketplaceIds=ATVPDKIKX0DER&includedData=summaries', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/'.$seller_id.'/'.$sku.'?marketplaceIds=ATVPDKIKX0DER&includedData=summaries', $request->url()); return true; }); @@ -129,8 +128,8 @@ public function testPutListingsItem() $http->assertSent(function (Request $request) use ($seller_id, $sku, $product_type) { $this->assertEquals('PUT', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/' . $seller_id . '/' . $sku . '?marketplaceIds=ATVPDKIKX0DER', urldecode($request->url())); - $this->assertEquals('{"productType":"' . $product_type . '","requirements":"LISTING","attributes":{"bullet_point":[{"value":"test","marketplace_id":"ATVPDKIKX0DER"},{"value":"test_2","marketplace_id":"ATVPDKIKX0DER"}],"externally_assigned_product_identifier":[{"value":"123456789","type":"ean"}],"item_package_dimensions":[{"length":{"value":"10","unit":"inches"}}]}}', $request->body()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/'.$seller_id.'/'.$sku.'?marketplaceIds=ATVPDKIKX0DER', urldecode($request->url())); + $this->assertEquals('{"productType":"'.$product_type.'","requirements":"LISTING","attributes":{"bullet_point":[{"value":"test","marketplace_id":"ATVPDKIKX0DER"},{"value":"test_2","marketplace_id":"ATVPDKIKX0DER"}],"externally_assigned_product_identifier":[{"value":"123456789","type":"ean"}],"item_package_dimensions":[{"length":{"value":"10","unit":"inches"}}]}}', $request->body()); return true; }); @@ -144,7 +143,6 @@ public function testDeleteListingsItem() product_type: Str::random(), requirements: 'LISTING', attributes: [ - ] ); $amzn = new AmznSPA($config); @@ -160,7 +158,7 @@ public function testDeleteListingsItem() $http->assertSent(function (Request $request) use ($seller_id, $sku) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/' . $seller_id . '/' . $sku, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/'.$seller_id.'/'.$sku, $request->url()); return true; }); @@ -193,7 +191,7 @@ public function testPatchListingsItem() $http->assertSent(function (Request $request) use ($seller_id, $sku) { $this->assertEquals('PATCH', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/' . $seller_id . '/' . $sku . '?marketplaceIds=ATVPDKIKX0DER', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/'.$seller_id.'/'.$sku.'?marketplaceIds=ATVPDKIKX0DER', urldecode($request->url())); return true; }); @@ -217,7 +215,7 @@ public function testGetListingsItemSkuIssues(string $sku): void $this->assertInstanceOf(GetListingsItemResponse::class, $response); $http->assertSent(function (Request $request) use ($sku, $seller_id) { - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/' . $seller_id . '/' . $sku . '?marketplaceIds=ATVPDKIKX0DER', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/listings/2021-08-01/items/'.$seller_id.'/'.$sku.'?marketplaceIds=ATVPDKIKX0DER', urldecode($request->url())); return true; }); diff --git a/tests/Unit/Resources/LwaResourceTest.php b/tests/Unit/Resources/LwaResourceTest.php index 1a42f806..d401b548 100644 --- a/tests/Unit/Resources/LwaResourceTest.php +++ b/tests/Unit/Resources/LwaResourceTest.php @@ -17,16 +17,14 @@ use Jasara\AmznSPA\Exceptions\AuthenticationException; use Jasara\AmznSPA\Tests\Setup\CallbackTestException; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; -/** - * @covers \Jasara\AmznSPA\Resources\LwaResource - * @covers \Jasara\AmznSPA\Exceptions\AuthenticationException - */ +#[CoversClass(\Jasara\AmznSPA\Resources\LwaResource::class)] +#[CoversClass(AuthenticationException::class)] class LwaResourceTest extends UnitTestCase { - /** - * @dataProvider marketplaces - */ + #[DataProvider('marketplaces')] public function testAuthUrlGenerated(Marketplace $marketplace) { $amzn = new AmznSPA($config = $this->setupMinimalConfig($marketplace->getIdentifier())); @@ -35,9 +33,7 @@ public function testAuthUrlGenerated(Marketplace $marketplace) $this->assertEquals($marketplace->getBaseUrl().'/apps/authorize/consent?redirect_url='.$config->getRedirectUrl(), $url); } - /** - * @dataProvider marketplaces - */ + #[DataProvider('marketplaces')] public function testAuthUrlGeneratedWithStateAndRedirectUrl(Marketplace $marketplace) { $state = Str::random(); diff --git a/tests/Unit/Resources/MerchantFulfillmentResourceTest.php b/tests/Unit/Resources/MerchantFulfillmentResourceTest.php index 97c9ac56..18fd1388 100644 --- a/tests/Unit/Resources/MerchantFulfillmentResourceTest.php +++ b/tests/Unit/Resources/MerchantFulfillmentResourceTest.php @@ -15,10 +15,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\MerchantFulfillment\GetShipmentResponse; use Jasara\AmznSPA\Tests\Setup\SetupMerchantFulfillmentRequest; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\MerchantFulfillmentResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\MerchantFulfillmentResource::class)] class MerchantFulfillmentResourceTest extends UnitTestCase { use SetupMerchantFulfillmentRequest; @@ -91,7 +90,7 @@ function (Request $request) { }, function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/mfn/v0/shipments/' . $shipment_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/mfn/v0/shipments/'.$shipment_id, $request->url()); return true; }, @@ -115,7 +114,7 @@ public function testCancelShipment() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/mfn/v0/shipments/' . $shipment_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/mfn/v0/shipments/'.$shipment_id, $request->url()); return true; }); @@ -136,7 +135,7 @@ public function testCancelShipmentOld() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('PUT', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/mfn/v0/shipments/' . $shipment_id . '/cancel', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/mfn/v0/shipments/'.$shipment_id.'/cancel', $request->url()); return true; }); @@ -171,7 +170,7 @@ public function testGetAdditionalSellerInputsOld() $request = new GetAdditionalSellerInputsRequest( shipping_service_id: Str::random(), ship_from_address: $this->setupAddress(), - order_id: STR::random() + order_id: Str::random() ); $amzn = new AmznSPA($config); @@ -195,7 +194,7 @@ public function testGetAdditionalSellerInputs() $request = new GetAdditionalSellerInputsRequest( shipping_service_id: Str::random(), ship_from_address: $this->setupAddress(), - order_id: STR::random() + order_id: Str::random() ); $amzn = new AmznSPA($config); diff --git a/tests/Unit/Resources/NotificationsResourceTest.php b/tests/Unit/Resources/NotificationsResourceTest.php index 1d5d96d2..1579c73d 100644 --- a/tests/Unit/Resources/NotificationsResourceTest.php +++ b/tests/Unit/Resources/NotificationsResourceTest.php @@ -17,10 +17,9 @@ use Jasara\AmznSPA\DataTransferObjects\Schemas\Notifications\DestinationSchema; use Jasara\AmznSPA\DataTransferObjects\Schemas\Notifications\ProcessingDirectiveSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\NotificationsResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\NotificationsResource::class)] class NotificationsResourceTest extends UnitTestCase { public function testGetSubscription() @@ -34,7 +33,7 @@ public function testGetSubscription() $this->assertInstanceOf(GetSubscriptionResponse::class, $response); $this->assertEquals('7fcacc7e-727b-11e9-8848-1681be663d3e', $response->payload->subscription_id); - $http->assertSent(function (Request $request) use ($config) { + $http->assertSent(function (Request $request) { $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/subscriptions/ANY_OFFER_CHANGED', $request->url()); return true; @@ -55,7 +54,7 @@ public function testGetSubscriptionById() $this->assertEquals('7fcacc7e-727b-11e9-8848-1681be663d3e', $response->payload->subscription_id); $http->assertSent(function (Request $request) use ($subscription_id) { - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/subscriptions/ANY_OFFER_CHANGED/' . $subscription_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/subscriptions/ANY_OFFER_CHANGED/'.$subscription_id, $request->url()); return true; }); @@ -75,7 +74,7 @@ public function testDeleteSubscriptionById() $http->assertSent(function (Request $request) use ($subscription_id) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/subscriptions/ANY_OFFER_CHANGED/' . $subscription_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/subscriptions/ANY_OFFER_CHANGED/'.$subscription_id, $request->url()); return true; }); @@ -161,7 +160,7 @@ public function testGetDestination() $http->assertSent(function (Request $request) use ($destination_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/destinations/' . $destination_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/destinations/'.$destination_id, $request->url()); return true; }); @@ -205,7 +204,7 @@ public function testDeleteDestination() $http->assertSent(function (Request $request) use ($destination_id) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/destinations/' . $destination_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/notifications/v1/destinations/'.$destination_id, $request->url()); return true; }); diff --git a/tests/Unit/Resources/OrdersResourceTest.php b/tests/Unit/Resources/OrdersResourceTest.php index c4cc16e4..f569cea2 100644 --- a/tests/Unit/Resources/OrdersResourceTest.php +++ b/tests/Unit/Resources/OrdersResourceTest.php @@ -15,10 +15,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\Orders\GetOrderResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\Orders\GetOrdersResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\OrdersResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\OrdersResource::class)] class OrdersResourceTest extends UnitTestCase { public function testGetOrders() @@ -63,7 +62,7 @@ function (Request $request) { }, function (Request $request) use ($created_after) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders?MarketplaceIds=ATVPDKIKX0DER&CreatedAfter=' . $created_after->tz('UTC')->format('Y-m-d\TH:i:s\Z') . '&OrderStatuses=Pending&FulfillmentChannels=MFN&BuyerEmail=tagrid@gmail.com&MaxResultsPerPage=10&StoreChainStoreId=ISPU_StoreId', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders?MarketplaceIds=ATVPDKIKX0DER&CreatedAfter='.$created_after->tz('UTC')->format('Y-m-d\TH:i:s\Z').'&OrderStatuses=Pending&FulfillmentChannels=MFN&BuyerEmail=tagrid@gmail.com&MaxResultsPerPage=10&StoreChainStoreId=ISPU_StoreId', urldecode($request->url())); return true; }, @@ -97,7 +96,7 @@ function (Request $request) { }, function (Request $request) use ($order_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/' . $order_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/'.$order_id, $request->url()); return true; }, @@ -138,7 +137,7 @@ public function testGetOrderBuyerInfo() $http->assertSent(function (Request $request) use ($order_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/' . $order_id . '/buyerInfo', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/'.$order_id.'/buyerInfo', $request->url()); return true; }); @@ -159,7 +158,7 @@ public function testGetOrderAddress() $http->assertSent(function (Request $request) use ($order_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/' . $order_id . '/address', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/'.$order_id.'/address', $request->url()); return true; }); @@ -187,7 +186,7 @@ function (Request $request) { }, function (Request $request) use ($order_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/' . $order_id . '/orderItems', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/'.$order_id.'/orderItems', $request->url()); return true; }, @@ -211,7 +210,7 @@ public function testGetOrderItemsBuyerInfo() $http->assertSent(function (Request $request) use ($order_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/' . $order_id . '/orderItems/buyerInfo', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/'.$order_id.'/orderItems/buyerInfo', $request->url()); return true; }); @@ -236,7 +235,7 @@ public function testUpdateShipmentStatus() $http->assertSent(function (Request $request) use ($order_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/' . $order_id . '/shipment', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/orders/v0/orders/'.$order_id.'/shipment', urldecode($request->url())); return true; }); diff --git a/tests/Unit/Resources/ProductFeesResourceTest.php b/tests/Unit/Resources/ProductFeesResourceTest.php index 20515056..3109cf6d 100644 --- a/tests/Unit/Resources/ProductFeesResourceTest.php +++ b/tests/Unit/Resources/ProductFeesResourceTest.php @@ -8,10 +8,9 @@ use Jasara\AmznSPA\DataTransferObjects\Requests\ProductFees\GetMyFeesEstimateRequest; use Jasara\AmznSPA\DataTransferObjects\Responses\ProductFees\GetMyFeesEstimateResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\ProductFeesResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\ProductFeesResource::class)] class ProductFeesResourceTest extends UnitTestCase { public function testGetMyFeesEstimateForSku() @@ -51,7 +50,7 @@ public function testGetMyFeesEstimateForSku() $http->assertSent(function (Request $request) use ($seller_sku) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/fees/v0/listings/' . $seller_sku . '/feesEstimate', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/fees/v0/listings/'.$seller_sku.'/feesEstimate', urldecode($request->url())); return true; }); @@ -94,7 +93,7 @@ public function testGetMyFeesEstimateForAsin() $http->assertSent(function (Request $request) use ($asin) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/fees/v0/items/' . $asin . '/feesEstimate', urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/fees/v0/items/'.$asin.'/feesEstimate', urldecode($request->url())); return true; }); diff --git a/tests/Unit/Resources/ProductPricingResourceTest.php b/tests/Unit/Resources/ProductPricingResourceTest.php index a32863cc..ed7f50d3 100644 --- a/tests/Unit/Resources/ProductPricingResourceTest.php +++ b/tests/Unit/Resources/ProductPricingResourceTest.php @@ -8,10 +8,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\ProductPricing\GetOffersResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\ProductPricing\GetPricingResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\ProductPricingResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\ProductPricingResource::class)] class ProductPricingResourceTest extends UnitTestCase { public function testGetPricing() @@ -104,7 +103,7 @@ public function testGetListingOffers() $http->assertSent(function (Request $request) use ($seller_sku) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/pricing/v0/listings/' . $seller_sku . '/offers?MarketplaceId=ATVPDKIKX0DER&ItemCondition=Club&CustomerType=Business', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/pricing/v0/listings/'.$seller_sku.'/offers?MarketplaceId=ATVPDKIKX0DER&ItemCondition=Club&CustomerType=Business', $request->url()); return true; }); @@ -137,7 +136,7 @@ public function testGetItemOffers() $http->assertSent(function (Request $request) use ($asin) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/pricing/v0/items/' . $asin . '/offers?MarketplaceId=ATVPDKIKX0DER&ItemCondition=New&CustomerType=Consumer', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/products/pricing/v0/items/'.$asin.'/offers?MarketplaceId=ATVPDKIKX0DER&ItemCondition=New&CustomerType=Consumer', $request->url()); return true; }); diff --git a/tests/Unit/Resources/ReportsResourceTest.php b/tests/Unit/Resources/ReportsResourceTest.php index 04047556..f2235e59 100644 --- a/tests/Unit/Resources/ReportsResourceTest.php +++ b/tests/Unit/Resources/ReportsResourceTest.php @@ -16,10 +16,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\Reports\GetReportSchedulesResponse; use Jasara\AmznSPA\DataTransferObjects\Responses\Reports\GetReportsResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\ReportsResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\ReportsResource::class)] class ReportsResourceTest extends UnitTestCase { public function testGetReports() @@ -33,7 +32,7 @@ public function testGetReports() $this->assertInstanceOf(GetReportsResponse::class, $response); $this->assertEquals('ReportId1', $response->reports->first()->report_id); - $http->assertSent(function (Request $request) use ($config) { + $http->assertSent(function (Request $request) { $this->assertEquals('GET', $request->method()); $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports?reportTypes=GET_MERCHANT_LISTINGS_ALL_DATA&marketplaceIds=ATVPDKIKX0DER&pageSize=10&processingStatuses=DONE', $request->url()); @@ -81,7 +80,7 @@ public function testGetReport() $http->assertSent(function (Request $request) use ($report_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports/' . $report_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports/'.$report_id, $request->url()); return true; }); @@ -101,7 +100,7 @@ public function testCancelReport() $http->assertSent(function (Request $request) use ($report_id) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports/' . $report_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports/'.$report_id, $request->url()); return true; }); @@ -165,7 +164,7 @@ public function testGetReportSchedule() $http->assertSent(function (Request $request) use ($report_schedule_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/schedules/' . $report_schedule_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/schedules/'.$report_schedule_id, $request->url()); return true; }); @@ -185,7 +184,7 @@ public function testCancelReportSchedule() $http->assertSent(function (Request $request) use ($report_schedule_id) { $this->assertEquals('DELETE', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/schedules/' . $report_schedule_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/schedules/'.$report_schedule_id, $request->url()); return true; }); @@ -206,7 +205,7 @@ public function testGetReportDocument() $http->assertSent(function (Request $request) use ($report_document_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/documents/' . $report_document_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/documents/'.$report_document_id, $request->url()); return true; }); diff --git a/tests/Unit/Resources/ResourceGetterTest.php b/tests/Unit/Resources/ResourceGetterTest.php index be970619..400996a1 100644 --- a/tests/Unit/Resources/ResourceGetterTest.php +++ b/tests/Unit/Resources/ResourceGetterTest.php @@ -2,40 +2,60 @@ namespace Jasara\AmznSPA\Tests\Unit\Resources; -use Jasara\AmznSPA\Resources; +use Jasara\AmznSPA\Resources\AuthorizationResource; +use Jasara\AmznSPA\Resources\CatalogItems\CatalogItems20201201Resource; +use Jasara\AmznSPA\Resources\CatalogItems\CatalogItems20220401Resource; +use Jasara\AmznSPA\Resources\FbaInboundEligibilityResource; +use Jasara\AmznSPA\Resources\FbaInventoryResource; +use Jasara\AmznSPA\Resources\FeedsResource; +use Jasara\AmznSPA\Resources\FulfillmentInboundResource; +use Jasara\AmznSPA\Resources\FulfillmentOutboundResource; +use Jasara\AmznSPA\Resources\ListingsItemsResource; +use Jasara\AmznSPA\Resources\LwaResource; +use Jasara\AmznSPA\Resources\MerchantFulfillmentResource; +use Jasara\AmznSPA\Resources\NotificationsResource; +use Jasara\AmznSPA\Resources\OrdersResource; +use Jasara\AmznSPA\Resources\ProductFeesResource; +use Jasara\AmznSPA\Resources\ProductPricingResource; +use Jasara\AmznSPA\Resources\ProductTypeDefinitionsResource; +use Jasara\AmznSPA\Resources\ReportsResource; +use Jasara\AmznSPA\Resources\ResourceGetter; +use Jasara\AmznSPA\Resources\SellersResource; +use Jasara\AmznSPA\Resources\ShippingResource; +use Jasara\AmznSPA\Resources\TokensResource; +use Jasara\AmznSPA\Resources\UploadsResource; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\TestWith; -/** - * @covers \Jasara\AmznSPA\Resources\ResourceGetter - */ +#[CoversClass(ResourceGetter::class)] class ResourceGetterTest extends UnitTestCase { - #[TestWith(['getAuthorization', Resources\AuthorizationResource::class])] - #[TestWith(['getCatalogItems', Resources\CatalogItems\CatalogItems20201201Resource::class])] - #[TestWith(['getCatalogItems20201201', Resources\CatalogItems\CatalogItems20201201Resource::class])] - #[TestWith(['getCatalogItems20220401', Resources\CatalogItems\CatalogItems20220401Resource::class])] - #[TestWith(['getFbaInboundEligibility', Resources\FbaInboundEligibilityResource::class])] - #[TestWith(['getFbaInventory', Resources\FbaInventoryResource::class])] - #[TestWith(['getFeeds', Resources\FeedsResource::class])] - #[TestWith(['getFulfillmentInbound', Resources\FulfillmentInboundResource::class])] - #[TestWith(['getFulfillmentOutbound', Resources\FulfillmentOutboundResource::class])] - #[TestWith(['getListingsItems', Resources\ListingsItemsResource::class])] - #[TestWith(['getLwa', Resources\LwaResource::class])] - #[TestWith(['getMerchantFulfillment', Resources\MerchantFulfillmentResource::class])] - #[TestWith(['getNotifications', Resources\NotificationsResource::class])] - #[TestWith(['getOrders', Resources\OrdersResource::class])] - #[TestWith(['getProductFees', Resources\ProductFeesResource::class])] - #[TestWith(['getProductPricing', Resources\ProductPricingResource::class])] - #[TestWith(['getProductTypeDefinitions', Resources\ProductTypeDefinitionsResource::class])] - #[TestWith(['getReports', Resources\ReportsResource::class])] - #[TestWith(['getSellers', Resources\SellersResource::class])] - #[TestWith(['getShipping', Resources\ShippingResource::class])] - #[TestWith(['getTokens', Resources\TokensResource::class])] - #[TestWith(['getUploads', Resources\UploadsResource::class])] + #[TestWith(['getAuthorization', AuthorizationResource::class])] + #[TestWith(['getCatalogItems', CatalogItems20201201Resource::class])] + #[TestWith(['getCatalogItems20201201', CatalogItems20201201Resource::class])] + #[TestWith(['getCatalogItems20220401', CatalogItems20220401Resource::class])] + #[TestWith(['getFbaInboundEligibility', FbaInboundEligibilityResource::class])] + #[TestWith(['getFbaInventory', FbaInventoryResource::class])] + #[TestWith(['getFeeds', FeedsResource::class])] + #[TestWith(['getFulfillmentInbound', FulfillmentInboundResource::class])] + #[TestWith(['getFulfillmentOutbound', FulfillmentOutboundResource::class])] + #[TestWith(['getListingsItems', ListingsItemsResource::class])] + #[TestWith(['getLwa', LwaResource::class])] + #[TestWith(['getMerchantFulfillment', MerchantFulfillmentResource::class])] + #[TestWith(['getNotifications', NotificationsResource::class])] + #[TestWith(['getOrders', OrdersResource::class])] + #[TestWith(['getProductFees', ProductFeesResource::class])] + #[TestWith(['getProductPricing', ProductPricingResource::class])] + #[TestWith(['getProductTypeDefinitions', ProductTypeDefinitionsResource::class])] + #[TestWith(['getReports', ReportsResource::class])] + #[TestWith(['getSellers', SellersResource::class])] + #[TestWith(['getShipping', ShippingResource::class])] + #[TestWith(['getTokens', TokensResource::class])] + #[TestWith(['getUploads', UploadsResource::class])] public function testGetsResource(string $function, string $expected_resource): void { - $resource_getter = new Resources\ResourceGetter($this->setupMinimalConfig()); + $resource_getter = new ResourceGetter($this->setupMinimalConfig()); $resource = $resource_getter->$function(); $this->assertInstanceOf($expected_resource, $resource); diff --git a/tests/Unit/Resources/SellersResourceTest.php b/tests/Unit/Resources/SellersResourceTest.php index 379e1d75..6fd30297 100644 --- a/tests/Unit/Resources/SellersResourceTest.php +++ b/tests/Unit/Resources/SellersResourceTest.php @@ -6,10 +6,9 @@ use Jasara\AmznSPA\AmznSPA; use Jasara\AmznSPA\DataTransferObjects\Responses\Sellers\GetMarketplaceParticipationsResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\SellersResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\SellersResource::class)] class SellersResourceTest extends UnitTestCase { public function testGetMarketplaceParticipations() diff --git a/tests/Unit/Resources/ShippingResourceTest.php b/tests/Unit/Resources/ShippingResourceTest.php index 4072721c..250e7e5a 100644 --- a/tests/Unit/Resources/ShippingResourceTest.php +++ b/tests/Unit/Resources/ShippingResourceTest.php @@ -21,10 +21,9 @@ use Jasara\AmznSPA\DataTransferObjects\Responses\Shipping\RetrieveShippingLabelResponse; use Jasara\AmznSPA\Tests\Setup\SetupContainers; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\ShippingResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\ShippingResource::class)] class ShippingResourceTest extends UnitTestCase { use SetupContainers; @@ -69,7 +68,7 @@ public function testGetShipment() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/' . $shipment_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/'.$shipment_id, $request->url()); return true; }); @@ -89,7 +88,7 @@ public function testCancelShipment() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/' . $shipment_id . '/cancel', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/'.$shipment_id.'/cancel', $request->url()); return true; }); @@ -117,7 +116,7 @@ public function testPurchaseLabels() $http->assertSent(function (Request $request) use ($shipment_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/' . $shipment_id . '/purchaseLabels', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/'.$shipment_id.'/purchaseLabels', $request->url()); return true; }); @@ -145,7 +144,7 @@ public function testRetrieveShippingLabel() $http->assertSent(function (Request $request) use ($shipment_id, $tracking_id) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/' . $shipment_id . '/containers' . '/' . $tracking_id . '/label', $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/shipments/'.$shipment_id.'/containers/'.$tracking_id.'/label', $request->url()); return true; }); @@ -253,7 +252,7 @@ public function testGetTrackingInformation() $http->assertSent(function (Request $request) use ($tracking_id) { $this->assertEquals('GET', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/tracking/' . $tracking_id, $request->url()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/shipping/v1/tracking/'.$tracking_id, $request->url()); return true; }); diff --git a/tests/Unit/Resources/TokensResourceTest.php b/tests/Unit/Resources/TokensResourceTest.php index 2afebb75..1be8e532 100644 --- a/tests/Unit/Resources/TokensResourceTest.php +++ b/tests/Unit/Resources/TokensResourceTest.php @@ -7,10 +7,9 @@ use Jasara\AmznSPA\DataTransferObjects\Requests\Tokens\CreateRestrictedDataTokenRequest; use Jasara\AmznSPA\DataTransferObjects\Responses\Tokens\CreateRestrictedDataTokenResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\TokensResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\TokensResource::class)] class TokensResourceTest extends UnitTestCase { public function testCreateRestrictedDataToken() diff --git a/tests/Unit/Resources/UploadsResourceTest.php b/tests/Unit/Resources/UploadsResourceTest.php index a48d2da3..d136c61e 100644 --- a/tests/Unit/Resources/UploadsResourceTest.php +++ b/tests/Unit/Resources/UploadsResourceTest.php @@ -7,10 +7,9 @@ use Jasara\AmznSPA\AmznSPA; use Jasara\AmznSPA\DataTransferObjects\Responses\Uploads\CreateUploadDestinationResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Resources\UploadsResource - */ +#[CoversClass(\Jasara\AmznSPA\Resources\UploadsResource::class)] class UploadsResourceTest extends UnitTestCase { public function testCreateUploadDestinationForResource() @@ -31,7 +30,7 @@ public function testCreateUploadDestinationForResource() $http->assertSent(function (Request $request) use ($resource) { $this->assertEquals('POST', $request->method()); - $this->assertEquals('https://sellingpartnerapi-na.amazon.com/uploads/2020-11-01/uploadDestinations/' . $resource, urldecode($request->url())); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/uploads/2020-11-01/uploadDestinations/'.$resource, urldecode($request->url())); return true; }); diff --git a/tests/Unit/Traits/HasConfigTest.php b/tests/Unit/Traits/HasConfigTest.php index 90b853b1..f181fa05 100644 --- a/tests/Unit/Traits/HasConfigTest.php +++ b/tests/Unit/Traits/HasConfigTest.php @@ -9,10 +9,9 @@ use Jasara\AmznSPA\DataTransferObjects\AuthTokensDTO; use Jasara\AmznSPA\Exceptions\AmznSPAException; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Traits\HasConfig - */ +#[CoversClass(\Jasara\AmznSPA\Traits\HasConfig::class)] class HasConfigTest extends UnitTestCase { public function testGetAccessTokenNotSetException() @@ -22,7 +21,7 @@ public function testGetAccessTokenNotSetException() $config = new AmznSPAConfig( marketplace_id: MarketplacesList::allIdentifiers()[rand(0, 15)], application_id: Str::random(), - redirect_url: Str::random() . '.com', + redirect_url: Str::random().'.com', lwa_refresh_token: Str::random(), aws_access_key: Str::random(), aws_secret_key: Str::random(), diff --git a/tests/Unit/Traits/ValidatesParametersTest.php b/tests/Unit/Traits/ValidatesParametersTest.php index 7afb1b19..6a915d18 100644 --- a/tests/Unit/Traits/ValidatesParametersTest.php +++ b/tests/Unit/Traits/ValidatesParametersTest.php @@ -2,6 +2,7 @@ namespace Jasara\AmznSPA\Tests\Unit\Traits; +use Exception; use Illuminate\Http\Client\RequestException; use Illuminate\Support\Str; use Jasara\AmznSPA\AmznSPA; @@ -13,10 +14,9 @@ use Jasara\AmznSPA\Resources\ResourceGetter; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; use Jasara\AmznSPA\Traits\ValidatesParameters; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers \Jasara\AmznSPA\Traits\ValidatesParameters - */ +#[CoversClass(ValidatesParameters::class)] class ValidatesParametersTest extends UnitTestCase { public function testRequiredParametersInObjectException() @@ -130,7 +130,7 @@ public function testValidatesStringEnumInvalidEnumClassPassed() $this->expectException(\Exception::class); $this->expectExceptionMessage('Only enum classes are allowed as string values for allowed_values.'); - $stub = new ResourceStub; + $stub = new ResourceStub(); $stub->passInvalidEnumClassToStringEnumValidator(); }