Skip to content

Commit

Permalink
Use rector to cover attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Apr 15, 2024
1 parent 9de7611 commit 19a46dc
Show file tree
Hide file tree
Showing 31 changed files with 203 additions and 210 deletions.
6 changes: 5 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
return RectorConfig::configure()
->withRules([
CoversAnnotationWithValueToAttributeRector::class,
]);
])
->withImportNames(
removeUnusedImports: true,
importDocBlockNames: true,
);
3 changes: 2 additions & 1 deletion tests/Unit/DataTransferObjects/AuthTokensDTOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/DataTransferObjects/Schemas/WeightSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 7 additions & 8 deletions tests/Unit/Resources/AuthorizationResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -31,15 +30,15 @@ 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;
});
}

public function testGetAuthorizationCodeNoAuthorizationExistsError()
{
$this->expectException(GrantlessAuthenticationException ::class);
$this->expectException(GrantlessAuthenticationException::class);

list($config, $http) = $this->setupConfigWithFakeHttp('authorization/no-authorization-exists-error', 400);

Expand All @@ -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;
});
Expand All @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
});
Expand All @@ -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');

Expand All @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'),
);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Resources/FbaInboundEligibilityResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 4 additions & 5 deletions tests/Unit/Resources/FbaInventoryResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand Down
11 changes: 5 additions & 6 deletions tests/Unit/Resources/FeedsResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
});
Expand All @@ -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;
});
Expand Down Expand Up @@ -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;
});
Expand Down
Loading

0 comments on commit 19a46dc

Please sign in to comment.