Skip to content

Commit 6306195

Browse files
committed
add testTransferMeta
1 parent d5d6498 commit 6306195

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/Units/Domain/TransactionsFilterTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,39 @@ public function testMetaAccount(): void
6363

6464
self::assertSame(3, $countByPeriods);
6565
}
66+
67+
public function testTransferMeta(): void
68+
{
69+
/**
70+
* @var Buyer $buyer1
71+
* @var Buyer $buyer2
72+
*/
73+
[$buyer1, $buyer2] = BuyerFactory::times(2)->create();
74+
$buyer1->deposit(1000);
75+
76+
self::assertSame(1000, $buyer1->balanceInt);
77+
78+
$buyer1->transfer($buyer2, 500, [
79+
'type' => 'credit',
80+
]);
81+
82+
self::assertSame(500, $buyer1->balanceInt);
83+
self::assertSame(500, $buyer2->balanceInt);
84+
85+
self::assertSame(2, $buyer1->transactions()->count());
86+
self::assertSame(1, $buyer2->transactions()->count());
87+
88+
$credits1 = $buyer1->transactions()
89+
->where('meta->type', 'credit')
90+
->count()
91+
;
92+
93+
$credits2 = $buyer2->transactions()
94+
->where('meta->type', 'credit')
95+
->count()
96+
;
97+
98+
self::assertSame(1, $credits1);
99+
self::assertSame(1, $credits2);
100+
}
66101
}

0 commit comments

Comments
 (0)