Skip to content

Commit

Permalink
[PLA-1896] Fix validation create beam on mint on demand (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner authored and leonardocustodio committed Jul 17, 2024
1 parent 880a735 commit 1ce8297
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 42 deletions.
6 changes: 2 additions & 4 deletions src/GraphQL/Mutations/CreateBeamMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
use Enjin\Platform\Beam\Rules\MaxTokenCount;
use Enjin\Platform\Beam\Rules\MaxTokenSupply;
use Enjin\Platform\Beam\Rules\TokensDoNotExistInBeam;
use Enjin\Platform\Beam\Rules\TokensDoNotExistInCollection;
use Enjin\Platform\Beam\Rules\TokensExistInCollection;
use Enjin\Platform\Beam\Rules\TokenUploadExistInCollection;
use Enjin\Platform\Beam\Rules\TokenUploadNotExistInBeam;
use Enjin\Platform\Beam\Rules\TokenUploadNotExistInCollection;
use Enjin\Platform\Beam\Rules\UniqueTokenIds;
use Enjin\Platform\Beam\Services\BeamService;
use Enjin\Platform\Models\Collection;
Expand Down Expand Up @@ -132,7 +130,7 @@ function (string $attribute, mixed $value, Closure $fail) {
'distinct',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute)))
? new TokensExistInCollection($args['collectionId'])
: new TokensDoNotExistInCollection($args['collectionId']),
: '',
new TokensDoNotExistInBeam(),
];
}),
Expand All @@ -143,7 +141,7 @@ function (string $attribute, mixed $value, Closure $fail) {
'prohibits:tokens.*.tokenIds',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute)))
? new TokenUploadExistInCollection($args['collectionId'])
: new TokenUploadNotExistInCollection($args['collectionId']),
: '',
new TokenUploadNotExistInBeam(),
];
}),
Expand Down
38 changes: 0 additions & 38 deletions tests/Feature/GraphQL/Mutations/CreateBeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,6 @@ public function test_it_can_create_beam_with_attribute_mint_on_demand(): void
*/
public function test_it_will_fail_to_create_beam_with_invalid_file_upload(): void
{
$file = UploadedFile::fake()->createWithContent('tokens.txt', $this->token->token_chain_id);
$response = $this->graphql($this->method, array_merge(
$this->generateBeamData(),
['tokens' => [['tokenIdDataUpload' => $file, 'type' => BeamType::MINT_ON_DEMAND->name]]]
), true);
$this->assertArraySubset([
'tokens.0.tokenIdDataUpload' => ['The tokens.0.tokenIdDataUpload exists in the specified collection.'],
], $response['error']);
Event::assertNotDispatched(BeamCreated::class);

$file = UploadedFile::fake()->createWithContent('tokens.txt', "{$this->token->token_chain_id}..{$this->token->token_chain_id}");
$response = $this->graphql($this->method, array_merge(
$this->generateBeamData(),
['tokens' => [['tokenIdDataUpload' => $file, 'type' => BeamType::MINT_ON_DEMAND->name]]]
), true);
$this->assertArraySubset([
'tokens.0.tokenIdDataUpload' => ['The tokens.0.tokenIdDataUpload exists in the specified collection.'],
], $response['error']);
Event::assertNotDispatched(BeamCreated::class);

$file = UploadedFile::fake()->createWithContent('tokens.txt', '1');
$response = $this->graphql($this->method, array_merge(
$this->generateBeamData(),
Expand All @@ -137,24 +117,6 @@ public function test_it_will_fail_to_create_beam_with_invalid_file_upload(): voi
Event::assertNotDispatched(BeamCreated::class);
}

/**
* Test creating beam token exist in collection.
*/
public function test_it_will_fail_with_token_exist(): void
{
$response = $this->graphql(
$this->method,
array_merge(
$this->generateBeamData(BeamType::MINT_ON_DEMAND),
['tokens' => [['tokenIds' => [$this->token->token_chain_id], 'type' => BeamType::MINT_ON_DEMAND->name]]]
),
true
);
$this->assertArraySubset([
'tokens.0.tokenIds' => ['The tokens.0.tokenIds exists in the specified collection.'],
], $response['error']);
}

/**
* Test creating beam token exist in beam.
*/
Expand Down

0 comments on commit 1ce8297

Please sign in to comment.