Skip to content

Commit

Permalink
ecs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bavixbot committed Feb 6, 2024
1 parent 4fe2e4d commit a993857
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/Internal/Assembler/TransferDtoAssembler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function __construct(
) {
}

/** @param array<mixed>|null $extra */
/**
* @param array<mixed>|null $extra
*/
public function create(
int $depositId,
int $withdrawId,
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Assembler/TransferDtoAssemblerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

interface TransferDtoAssemblerInterface
{
/** @param array<mixed>|null $extra */
/**
* @param array<mixed>|null $extra
*/
public function create(
int $depositId,
int $withdrawId,
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Assembler/TransferLazyDtoAssembler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

final class TransferLazyDtoAssembler implements TransferLazyDtoAssemblerInterface
{
/** @param array<mixed>|null $extra */
/**
* @param array<mixed>|null $extra
*/
public function create(
Wallet $fromWallet,
Wallet $toWallet,
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Assembler/TransferLazyDtoAssemblerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

interface TransferLazyDtoAssemblerInterface
{
/** @param array<mixed>|null $extra */
/**
* @param array<mixed>|null $extra
*/
public function create(
Wallet $fromWallet,
Wallet $toWallet,
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Dto/TransferDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
/** @immutable */
final readonly class TransferDto implements TransferDtoInterface
{
/** @param array<mixed>|null $extra */
/**
* @param array<mixed>|null $extra
*/
public function __construct(
private string $uuid,
private int $depositId,
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Dto/TransferDtoInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public function getDiscount(): int;

public function getFee(): string;

/** @return array<mixed>|null */
/**
* @return array<mixed>|null
*/
public function getExtra(): ?array;

public function getCreatedAt(): DateTimeImmutable;
Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Dto/TransferLazyDtoInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function getStatus(): string;

public function getUuid(): ?string;

/** @return array<mixed>|null */
/**
* @return array<mixed>|null
*/
public function getExtra(): ?array;
}
1 change: 0 additions & 1 deletion src/Models/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Bavix\Wallet\Internal\Service\MathServiceInterface;
use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface;
use Bavix\Wallet\Services\AtomicServiceInterface;
use Bavix\Wallet\Services\CastServiceInterface;
use Bavix\Wallet\Services\RegulatorServiceInterface;
use Bavix\Wallet\Traits\CanConfirm;
use Bavix\Wallet\Traits\CanExchange;
Expand Down
56 changes: 42 additions & 14 deletions tests/Units/Api/TransferHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,67 @@ public function testWalletNotExists(): void
null,
null,
'598c184c-e6d6-4fc2-9640-c1c7acb38093',
['type' => 'first'],
[
'type' => 'first',
],
),
),
new TransferQuery($from, $to, 100,
new TransferQuery(
$from,
$to,
100,
new Extra(
null,
null,
'f303d60d-c2de-45d0-b9ed-e1487429709a',
['type' => 'second'],
)),
new TransferQuery($to, $from, 50,
[
'type' => 'second',
],
)
),
new TransferQuery(
$to,
$from,
50,
new Extra(
null,
null,
'7f0175fe-99cc-4058-92c6-157f0da18243',
['type' => 'third'],
)),
new TransferFloatQuery($to, $from, .50,
[
'type' => 'third',
],
)
),
new TransferFloatQuery(
$to,
$from,
.50,
new Extra(
null,
null,
'1a7326a6-dfdf-4ec8-afc4-cb21cf1f43c6',
['type' => 'fourth'],
)),
[
'type' => 'fourth',
],
)
),
]);

self::assertSame(-100, $from->balanceInt);
self::assertSame(100, $to->balanceInt);
self::assertCount(4, $transfers);

self::assertSame(['type' => 'first'], $transfers['598c184c-e6d6-4fc2-9640-c1c7acb38093']->extra);
self::assertSame(['type' => 'second'], $transfers['f303d60d-c2de-45d0-b9ed-e1487429709a']->extra);
self::assertSame(['type' => 'third'], $transfers['7f0175fe-99cc-4058-92c6-157f0da18243']->extra);
self::assertSame(['type' => 'fourth'], $transfers['1a7326a6-dfdf-4ec8-afc4-cb21cf1f43c6']->extra);
self::assertSame([
'type' => 'first',
], $transfers['598c184c-e6d6-4fc2-9640-c1c7acb38093']->extra);
self::assertSame([
'type' => 'second',
], $transfers['f303d60d-c2de-45d0-b9ed-e1487429709a']->extra);
self::assertSame([
'type' => 'third',
], $transfers['7f0175fe-99cc-4058-92c6-157f0da18243']->extra);
self::assertSame([
'type' => 'fourth',
], $transfers['1a7326a6-dfdf-4ec8-afc4-cb21cf1f43c6']->extra);
}
}
8 changes: 6 additions & 2 deletions tests/Units/Domain/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public function testCartClone(): void

$cartWithItems = $cart->withItems([$product]);
$cartWithMeta = $cart
->withMeta(['product_id' => $product->getKey()])
->withExtra(['products' => count($cartWithItems->getItems())])
->withMeta([
'product_id' => $product->getKey(),
])
->withExtra([
'products' => count($cartWithItems->getItems()),
])
;

self::assertCount(0, $cart->getItems());
Expand Down
2 changes: 1 addition & 1 deletion tests/Units/Domain/DiscountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use Bavix\Wallet\Test\Infra\Factories\ItemDiscountFactory;
use Bavix\Wallet\Test\Infra\Models\Buyer;
use Bavix\Wallet\Test\Infra\Models\ItemDiscount;
use Bavix\Wallet\Test\Infra\TestCase;
use Bavix\Wallet\Test\Infra\PackageModels\Transaction as InfraTransaction;
use Bavix\Wallet\Test\Infra\PackageModels\Wallet as InfraWallet;
use Bavix\Wallet\Test\Infra\TestCase;

/**
* @internal
Expand Down
4 changes: 3 additions & 1 deletion tests/Units/Domain/ExtraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function testExtraTransferWithdraw(): void
],
false
),
extra: ['msg' => 'hello world'],
extra: [
'msg' => 'hello world',
],
)
);

Expand Down

0 comments on commit a993857

Please sign in to comment.