10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
46
tests/Unit/Services/AboOrdersOverviewTest.php
Normal file
46
tests/Unit/Services/AboOrdersOverviewTest.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\SyS\AboOrdersOverview;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
it('summiert nur erfolgreiche shopping_payments (Cent)', function () {
|
||||
$order = new ShoppingOrder(['total_shipping' => 119.00]);
|
||||
$failed = new ShoppingPayment(['amount' => 10000]);
|
||||
$failed->txaction = 'failed';
|
||||
$paid = new ShoppingPayment(['amount' => 11900]);
|
||||
$paid->txaction = 'paid';
|
||||
$order->setRelation('shopping_payments', collect([$failed, $paid]));
|
||||
|
||||
expect(AboOrdersOverview::actualChargedCentsFromPayments($order))->toBe(11900);
|
||||
});
|
||||
|
||||
it('addiert mehrere erfolgreiche Zahlungen', function () {
|
||||
$order = new ShoppingOrder;
|
||||
$p1 = new ShoppingPayment(['amount' => 5000]);
|
||||
$p1->txaction = 'paid';
|
||||
$p2 = new ShoppingPayment(['amount' => 6900]);
|
||||
$p2->txaction = 'extern_paid';
|
||||
$order->setRelation('shopping_payments', collect([$p1, $p2]));
|
||||
|
||||
expect(AboOrdersOverview::actualChargedCentsFromPayments($order))->toBe(11900);
|
||||
});
|
||||
|
||||
it('liefert null wenn keine erfolgreiche Zahlung existiert', function () {
|
||||
$order = new ShoppingOrder;
|
||||
$failed = new ShoppingPayment(['amount' => 10000]);
|
||||
$failed->txaction = 'failed';
|
||||
$order->setRelation('shopping_payments', collect([$failed]));
|
||||
|
||||
expect(AboOrdersOverview::actualChargedCentsFromPayments($order))->toBeNull();
|
||||
});
|
||||
|
||||
it('liefert null bei leeren Zahlungen', function () {
|
||||
$order = new ShoppingOrder;
|
||||
$order->setRelation('shopping_payments', collect());
|
||||
|
||||
expect(AboOrdersOverview::actualChargedCentsFromPayments($order))->toBeNull();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue