Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/TransactionTest.php
Show All 20 Lines | public function testLabels(): void | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
// Create transactions | // Create transactions | ||||
$transaction = Transaction::create([ | $transaction = Transaction::create([ | ||||
'object_id' => $wallet->id, | 'object_id' => $wallet->id, | ||||
'object_type' => Wallet::class, | 'object_type' => Wallet::class, | ||||
'type' => Transaction::WALLET_PENALTY, | 'type' => Transaction::WALLET_PENALTY, | ||||
'amount' => 9, | 'amount' => -10, | ||||
'description' => "A test penalty" | 'description' => "A test penalty" | ||||
]); | ]); | ||||
$transaction = Transaction::create([ | $transaction = Transaction::create([ | ||||
'object_id' => $wallet->id, | 'object_id' => $wallet->id, | ||||
'object_type' => Wallet::class, | 'object_type' => Wallet::class, | ||||
'type' => Transaction::WALLET_DEBIT, | 'type' => Transaction::WALLET_DEBIT, | ||||
'amount' => 10 | 'amount' => -9 | ||||
]); | ]); | ||||
$transaction = Transaction::create([ | $transaction = Transaction::create([ | ||||
'object_id' => $wallet->id, | 'object_id' => $wallet->id, | ||||
'object_type' => Wallet::class, | 'object_type' => Wallet::class, | ||||
'type' => Transaction::WALLET_CREDIT, | 'type' => Transaction::WALLET_CREDIT, | ||||
'amount' => 11 | 'amount' => 11 | ||||
]); | ]); | ||||
Show All 33 Lines | public function testLabels(): void | ||||
'object_id' => $entitlement->id, | 'object_id' => $entitlement->id, | ||||
'object_type' => Entitlement::class, | 'object_type' => Entitlement::class, | ||||
'type' => Transaction::ENTITLEMENT_DELETED, | 'type' => Transaction::ENTITLEMENT_DELETED, | ||||
'amount' => 15 | 'amount' => 15 | ||||
]); | ]); | ||||
$transactions = Transaction::where('amount', '<', 20)->orderBy('amount')->get(); | $transactions = Transaction::where('amount', '<', 20)->orderBy('amount')->get(); | ||||
$this->assertSame(9, $transactions[0]->amount); | $this->assertSame(-10, $transactions[0]->amount); | ||||
$this->assertSame(Transaction::WALLET_PENALTY, $transactions[0]->type); | $this->assertSame(Transaction::WALLET_PENALTY, $transactions[0]->type); | ||||
$this->assertSame( | $this->assertSame( | ||||
"The balance of Default wallet was reduced by 0,09 CHF; A test penalty", | "The balance of Default wallet was reduced by 0,10 CHF; A test penalty", | ||||
$transactions[0]->toString() | $transactions[0]->toString() | ||||
); | ); | ||||
$this->assertSame( | $this->assertSame( | ||||
"Charge: A test penalty", | "Charge: A test penalty", | ||||
$transactions[0]->shortDescription() | $transactions[0]->shortDescription() | ||||
); | ); | ||||
$this->assertSame(10, $transactions[1]->amount); | $this->assertSame(-9, $transactions[1]->amount); | ||||
$this->assertSame(Transaction::WALLET_DEBIT, $transactions[1]->type); | $this->assertSame(Transaction::WALLET_DEBIT, $transactions[1]->type); | ||||
$this->assertSame( | $this->assertSame( | ||||
"0,10 CHF was deducted from the balance of Default wallet", | "0,09 CHF was deducted from the balance of Default wallet", | ||||
$transactions[1]->toString() | $transactions[1]->toString() | ||||
); | ); | ||||
$this->assertSame( | $this->assertSame( | ||||
"Deduction", | "Deduction", | ||||
$transactions[1]->shortDescription() | $transactions[1]->shortDescription() | ||||
); | ); | ||||
$this->assertSame(11, $transactions[2]->amount); | $this->assertSame(11, $transactions[2]->amount); | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |