Skip to content

Commit

Permalink
[PLA-1629] Fixes MarketplaceSale (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Jun 12, 2024
1 parent 05d7c65 commit df97698
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('marketplace_sales', function (Blueprint $table) {
$table->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();
});
}
};
2 changes: 1 addition & 1 deletion src/GraphQL/Types/MarketplaceSaleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand Down
3 changes: 3 additions & 0 deletions src/MarketplaceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
18 changes: 18 additions & 0 deletions tests/Feature/GraphQL/Queries/GetSaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}

Expand Down

0 comments on commit df97698

Please sign in to comment.