46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?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();
|
|
});
|