From df97698aa3540a87c65cb1916219f8be3a51d394 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Wed, 12 Jun 2024 08:47:56 -0300 Subject: [PATCH] [PLA-1629] Fixes MarketplaceSale (#51) --- ...ble_listing_on_marketplace_sales_table.php | 27 +++++++++++++++++++ src/GraphQL/Types/MarketplaceSaleType.php | 2 +- src/MarketplaceServiceProvider.php | 3 +++ tests/Feature/GraphQL/Queries/GetSaleTest.php | 18 +++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2024_06_23_083100_nullable_listing_on_marketplace_sales_table.php diff --git a/database/migrations/2024_06_23_083100_nullable_listing_on_marketplace_sales_table.php b/database/migrations/2024_06_23_083100_nullable_listing_on_marketplace_sales_table.php new file mode 100644 index 0000000..84bdedd --- /dev/null +++ b/database/migrations/2024_06_23_083100_nullable_listing_on_marketplace_sales_table.php @@ -0,0 +1,27 @@ +string('listing_chain_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('marketplace_sales', function (Blueprint $table) { + $table->string('listing_chain_id')->index()->change(); + }); + } +}; diff --git a/src/GraphQL/Types/MarketplaceSaleType.php b/src/GraphQL/Types/MarketplaceSaleType.php index 85a2a42..fea1374 100644 --- a/src/GraphQL/Types/MarketplaceSaleType.php +++ b/src/GraphQL/Types/MarketplaceSaleType.php @@ -44,7 +44,7 @@ public function fields(): array 'is_relation' => true, ], 'listing' => [ - 'type' => GraphQL::type('MarketplaceListing!'), + 'type' => GraphQL::type('MarketplaceListing'), 'description' => __('enjin-platform-marketplace::type.marketplace_listing.description'), 'is_relation' => true, ], diff --git a/src/MarketplaceServiceProvider.php b/src/MarketplaceServiceProvider.php index 130fa89..0c5de14 100644 --- a/src/MarketplaceServiceProvider.php +++ b/src/MarketplaceServiceProvider.php @@ -21,6 +21,9 @@ public function configurePackage(Package $package): void ->hasMigration('create_marketplace_bids_table') ->hasMigration('create_marketplace_sales_table') ->hasMigration('create_marketplace_states_table') + ->hasMigration('add_listing_id_to_marketplace_sales_table') + ->hasMigration('drop_market_place_listing_id_in_marketplace_sales_table') + ->hasMigration('nullable_listing_on_marketplace_sales_table') ->hasTranslations(); } diff --git a/tests/Feature/GraphQL/Queries/GetSaleTest.php b/tests/Feature/GraphQL/Queries/GetSaleTest.php index 1b8a4cd..2d57408 100644 --- a/tests/Feature/GraphQL/Queries/GetSaleTest.php +++ b/tests/Feature/GraphQL/Queries/GetSaleTest.php @@ -4,6 +4,7 @@ use Enjin\Platform\Marketplace\Tests\Feature\GraphQL\TestCaseGraphQL; use Enjin\Platform\Support\Hex; +use Illuminate\Support\Facades\Schema; class GetSaleTest extends TestCaseGraphQL { @@ -19,6 +20,23 @@ public function test_it_can_get_sale(): void $this->method, ['id' => $listing->sales->first()->id] ); + + $this->assertNotEmpty($response); + } + + public function test_it_can_get_a_sale_with_no_listing(): void + { + Schema::disableForeignKeyConstraints(); + $listing = $this->createListing(); + $saleId = $listing->sales->first()->id; + $listing->delete(); + Schema::enableForeignKeyConstraints(); + + $response = $this->graphql( + $this->method, + ['id' => $saleId] + ); + $this->assertNotEmpty($response); }