makeShopEnv()); it('rendert die Einmal-Produktliste mit Position und Zwischensumme', function () { $abo = makeMeAbo(); $product = makeProduct(['2'], 119, 19); UserAboOneTimeItem::create([ 'user_abo_id' => $abo->id, 'product_id' => $product->id, 'qty' => 2, 'price' => 119.0, 'price_net' => 100.0, 'tax_rate' => 19.0, 'tax' => 19.0, 'status' => 1, ]); $summary = ['one_time' => ['gross' => 238.0, 'net' => 200.0, 'tax' => 38.0]]; $html = view('admin.abo._order_onetime_show', [ 'user_abo' => $abo->fresh(), 'summary' => $summary, ])->render(); expect($html)->toContain($product->getLang('name')) ->and($html)->toContain(__('abo.onetime_subtotal')) ->and($html)->toContain('238,00'); }); it('zeigt bei unbestätigten Einmal-Artikeln die Bestätigungsbuttons', function () { $abo = makeMeAbo(); $product = makeProduct(['2'], 119, 19); UserAboOneTimeItem::create([ 'user_abo_id' => $abo->id, 'product_id' => $product->id, 'qty' => 1, 'price' => 119.0, 'price_net' => 100.0, 'tax_rate' => 19.0, 'tax' => 19.0, 'status' => 0, ]); $html = view('admin.abo._order_onetime_show', [ 'user_abo' => $abo->fresh(), 'summary' => ['one_time' => ['gross' => 119.0], 'total_with_shipping' => 219.0], ])->render(); expect($html)->toContain(__('abo.onetime_next_delivery_total')) ->and($html)->toContain(__('abo.onetime_legal_notice', [ 'nextBillingDate' => $abo->next_date, 'agb' => ''.__('abo.confirm_terms_link').'', 'withdrawal' => ''.__('abo.confirm_withdrawal_link').'', ])) ->and($html)->toContain(__('abo.onetime_discard_changes')) ->and($html)->toContain(__('abo.onetime_confirm_paid')); }); it('zeigt bei bestätigten Einmal-Artikeln den Erfolgshinweis', function () { $abo = makeMeAbo(); $product = makeProduct(['2'], 119, 19); UserAboOneTimeItem::create([ 'user_abo_id' => $abo->id, 'product_id' => $product->id, 'qty' => 1, 'confirmed_qty' => 1, 'confirmed_at' => now(), 'price' => 119.0, 'price_net' => 100.0, 'tax_rate' => 19.0, 'tax' => 19.0, 'status' => 1, ]); $html = view('admin.abo._order_onetime_show', [ 'user_abo' => $abo->fresh(), 'summary' => ['one_time' => ['gross' => 119.0], 'total_with_shipping' => 219.0], ])->render(); expect($html)->toContain(__('abo.onetime_confirm_success')) ->and($html)->toContain('data-confirmation-state="confirmed"') ->and($html)->not->toContain(__('abo.onetime_confirm_paid')); }); it('zeigt nach einer Änderung an bestätigten Einmal-Artikeln wieder die Bestätigungsbuttons', function () { $abo = makeMeAbo(); $product = makeProduct(['2'], 119, 19); UserAboOneTimeItem::create([ 'user_abo_id' => $abo->id, 'product_id' => $product->id, 'qty' => 3, 'confirmed_qty' => 1, 'confirmed_at' => now(), 'price' => 119.0, 'price_net' => 100.0, 'tax_rate' => 19.0, 'tax' => 19.0, 'status' => 0, ]); $html = view('admin.abo._order_onetime_show', [ 'user_abo' => $abo->fresh(), 'summary' => ['one_time' => ['gross' => 357.0], 'total_with_shipping' => 457.0], ])->render(); expect($html)->toContain('data-confirmation-state="changed"') ->and($html)->toContain(__('abo.onetime_discard_changes')) ->and($html)->toContain(__('abo.onetime_confirm_paid')) ->and($html)->not->toContain(__('abo.onetime_confirm_success')); }); it('zeigt den Leer-Hinweis, wenn keine Einmal-Produkte vorhanden sind', function () { $abo = makeMeAbo(); $html = view('admin.abo._order_onetime_show', [ 'user_abo' => $abo, 'summary' => ['one_time' => ['gross' => 0]], ])->render(); expect($html)->toContain(__('abo.onetime_empty')); }); it('rendert die kombinierte Gesamtsumme mit getrennten Zwischensummen', function () { $yard = Yard::instance(AboOrderCart::INSTANCE); $yard->destroy(); $aboRow = $yard->add(1, 'Abo-Produkt', 1, 119.0, false, false, ['weight' => 100]); Yard::setTax($aboRow->rowId, 19.0); $oneTimeRow = $yard->add(2, 'Einmal-Produkt', 1, 59.5, false, false, ['weight' => 100, 'abo_addon' => true]); Yard::setTax($oneTimeRow->rowId, 19.0); $summary = AboOrderCart::getSplitSummary(); $html = view('admin.abo._order_combined_summary', ['summary' => $summary])->render(); expect($html)->toContain(__('abo.combined_summary_hl')) ->and($html)->toContain(__('abo.onetime_subtotal')) ->and($html)->toContain(__('abo.abo_subtotal')) ->and($html)->toContain(__('order.total_sum')); $yard->destroy(); }); it('rendert die Abo-Liste im Split-Modus mit Abo-Zwischensumme und Endsumme', function () { $abo = makeMeAbo(); $yard = Yard::instance(AboOrderCart::INSTANCE); $yard->destroy(); $aboRow = $yard->add(1, 'Abo-Produkt', 1, 119.0, false, false, ['weight' => 100]); Yard::setTax($aboRow->rowId, 19.0); $summary = AboOrderCart::getSplitSummary(); $html = view('admin.abo._order_abo_show', [ 'user_abo' => $abo, 'split_mode' => true, 'summary' => $summary, 'only_show_products' => false, 'add_only_mode' => false, ])->render(); expect($html)->toContain(__('abo.abo_subtotal')) ->and($html)->toContain(__('abo.abo_next_delivery_total')) ->and($html)->not->toContain(__('order.shipping_costs')) ->and($html)->not->toContain(__('order.total_sum')); $yard->destroy(); }); it('rendert den Bestätigungsdialog für kostenpflichtige Abo-Erhöhungen', function () { $abo = makeMeAbo(); $abo->amount = 1760; $abo->save(); $html = view('admin.abo._confirm_add_modal', [ 'user_abo' => $abo, ])->render(); expect($html)->toContain(__('abo.confirm_increase_title')) ->and($html)->toContain(__('abo.confirm_increase_info')) ->and($html)->toContain(__('abo.confirm_new_total')) ->and($html)->toContain(__('abo.confirm_legal_notice', [ 'nextBillingDate' => '', 'agb' => ''.__('abo.confirm_terms_link').'', 'withdrawal' => ''.__('abo.confirm_withdrawal_link').'', ])) ->and($html)->toContain(__('abo.confirm_add_ok')); }); });