Trenne Shop sichtbar und Checkout offen und kaufe nur noch ueber die Kasse
- Zwei Schalter: Shop::visible (SHOP_PUBLIC) und Shop::checkoutOpen; ist der Shop nur sichtbar, fuehren Warenkorb, Kasse und Jetzt kaufen auf eine Hinweisseite (noindex), ohne Warenkorb und Bestellung - Einzelkauf (Checkout::place, Route member.offers.buy) entfernt; Bestellung nur aus dem Warenkorb - Jetzt kaufen an der Produktseite oeffnet die Bestellübersicht, Bereits erworben auf der Produktseite - Menuepunkte in den Shop nur bei sichtbarem Shop, /angebote leitet auf /shop, Seeder fuehrt Shop - Mitgliederseite Angebote zeigt nur kostenlose Angebote zum Uebernehmen - Middleware EnsureCheckoutOpen laeuft vor der Anmeldepruefung - Plan und ADR-53, DEPLOYMENT.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28e3342b1f
commit
3d76062097
36 files changed
+756
-150
No files matched your search
@@ -65,7 +65,7 @@ public function test_legacy_page_survives_a_round_trip_through_the_editor(): voi
|
||||
}
|
||||
}
|
||||
|
||||
private const LEGACY_PAGES = ['/' => 'home', '/praevention' => 'praevention', '/materialien' => 'materialien', '/angebote' => 'angebote', '/trainer' => 'trainer', '/ueber' => 'ueber', '/impressum' => 'impressum', '/datenschutz' => 'datenschutz'];
|
||||
private const LEGACY_PAGES = ['/' => 'home', '/praevention' => 'praevention', '/materialien' => 'materialien', '/trainer' => 'trainer', '/ueber' => 'ueber', '/impressum' => 'impressum', '/datenschutz' => 'datenschutz'];
|
||||
|
||||
/**
|
||||
* Auf Test und Produktion liegen die Seiten im flachen Format vor der Registry. Die Migration ruft den
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Support\PlacesOrders;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MembershipAccessTest extends TestCase
|
||||
{
|
||||
use PlacesOrders;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_a_free_offer_is_claimed_once_per_member(): void
|
||||
@@ -77,14 +79,14 @@ public function test_test_payment_grants_once_and_a_failure_grants_nothing(): vo
|
||||
[$article, $offer] = $this->paidOffer();
|
||||
$member = User::factory()->create();
|
||||
$checkout = app(Checkout::class);
|
||||
$order = $checkout->place($member, $offer);
|
||||
$order = $this->orderOf($member, [$offer]);
|
||||
$second = $this->orderOf($member, [$offer]);
|
||||
$checkout->confirmTestPayment($order, 'test-1');
|
||||
$checkout->confirmTestPayment($order->fresh(), 'test-2');
|
||||
|
||||
$this->assertSame(1, Grant::query()->where('license_article_id', $article->id)->count());
|
||||
Mail::assertSent(OrderConfirmed::class, 1);
|
||||
|
||||
$second = $checkout->place($member, $offer);
|
||||
$checkout->failTestPayment($second, 'test-fail-1');
|
||||
|
||||
$this->assertSame('fehlgeschlagen', $second->fresh()->status);
|
||||
@@ -131,7 +133,7 @@ public function test_refund_revokes_the_grant(): void
|
||||
[, $offer] = $this->paidOffer();
|
||||
$member = User::factory()->create();
|
||||
$checkout = app(Checkout::class);
|
||||
$order = $checkout->place($member, $offer);
|
||||
$order = $this->orderOf($member, [$offer]);
|
||||
$checkout->confirmTestPayment($order, 'test-refund');
|
||||
$checkout->refund($order->fresh(), 'Testwiderruf');
|
||||
|
||||
|
||||
@@ -11,16 +11,17 @@
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Support\PlacesOrders;
|
||||
use Tests\TestCase;
|
||||
|
||||
class OfferVersioningTest extends TestCase
|
||||
{
|
||||
use PlacesOrders;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_a_second_activation_leaves_one_active_version_and_keeps_the_first_intact(): void
|
||||
@@ -103,7 +104,7 @@ public function test_order_line_stores_offer_name_and_keeps_it_when_the_offer_is
|
||||
], ['grant_kind' => 'kauf', 'price_cents' => 1200]);
|
||||
|
||||
$member = User::factory()->create();
|
||||
$order = app(Checkout::class)->place($member, $offer);
|
||||
$order = $this->orderOf($member, [$offer]);
|
||||
$line = $order->lines()->first();
|
||||
|
||||
$this->assertSame('Testangebot', $line->offer_name);
|
||||
|
||||
@@ -26,7 +26,7 @@ public function test_home_page_is_published_from_the_cms(): void
|
||||
public function test_known_pages_and_sitemap_are_available(): void
|
||||
{
|
||||
$this->get('/praevention')->assertOk()->assertSee('Prävention im Alltag');
|
||||
$this->get('/angebote')->assertOk()->assertDontSee('€');
|
||||
$this->get('/angebote')->assertRedirect(route('shop'));
|
||||
$this->get('/sitemap.xml')->assertOk()->assertSee(url('/praevention'), false);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ public function test_the_shop_stays_off_in_production_unless_released_keyed_and_
|
||||
config(['services.payment.driver' => 'stripe', 'services.stripe.secret' => 'sk_live_nur_fuer_tests']);
|
||||
|
||||
$this->assertFalse(config('shop.live_release'), 'Die Freigabe ist standardmäßig aus.');
|
||||
$this->assertFalse(Shop::enabled());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->assertFalse(Shop::stripe());
|
||||
|
||||
config(['shop.live_release' => true]);
|
||||
@@ -297,7 +297,7 @@ public function test_the_shop_stays_off_in_production_unless_released_keyed_and_
|
||||
}
|
||||
|
||||
$this->assertTrue(Shop::live());
|
||||
$this->assertTrue(Shop::enabled());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
$this->assertTrue(Shop::stripe());
|
||||
|
||||
config(['services.stripe.secret' => 'sk_test_nur_fuer_tests']);
|
||||
@@ -404,12 +404,7 @@ public function test_in_live_mode_only_the_checkout_with_consents_creates_an_ord
|
||||
$this->assertTrue(Shop::live());
|
||||
$tina = $this->tina();
|
||||
|
||||
try {
|
||||
app(Checkout::class)->place($tina, $this->privateKonflikte());
|
||||
$this->fail('Der alte Einzelkauf kennt keine Pflichtangaben und ist im Livebetrieb gesperrt.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
}
|
||||
$this->assertFalse(method_exists(Checkout::class, 'place'), 'Der frühere Einzelkauf ohne Pflichtangaben ist entfernt.');
|
||||
|
||||
$cart = app(Cart::class);
|
||||
$cart->add($this->privateKonflikte());
|
||||
|
||||
@@ -97,7 +97,7 @@ public function test_free_and_unpriced_offers_are_not_shown_as_purchasable(): vo
|
||||
|
||||
public function test_the_shop_exists_only_with_test_payment_and_never_in_production(): void
|
||||
{
|
||||
$this->assertTrue(Shop::enabled());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
|
||||
// Ein nicht freigegebener Zahlungsweg (Stripe ist seit der Sandbox-Anbindung freigegeben, siehe StripeSandboxTest).
|
||||
config(['services.payment.driver' => 'unbekannt']);
|
||||
@@ -113,7 +113,7 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
||||
|
||||
config(['services.payment.driver' => 'test']);
|
||||
$this->app['env'] = 'production';
|
||||
$this->assertFalse(Shop::enabled());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\ShopDemoSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Zwei Schalter für Produktion: „Shop sichtbar“ (SHOP_PUBLIC) zeigt Shop und Produktseiten, „Checkout offen“
|
||||
* (SHOP_LIVE_RELEASE mit Live-Schlüssel und Rechtstexten) öffnet Warenkorb, Kasse und Zahlung. Dazu: Der alte Einzelkauf
|
||||
* auf der Mitgliederseite ist entfernt, „Jetzt kaufen“ führt über die Kasse mit allen Pflichtangaben.
|
||||
*/
|
||||
class ShopSwitchTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
private function publishLegalPages(): void
|
||||
{
|
||||
foreach (['/agb', '/lizenzbedingungen', '/widerruf', '/impressum', '/datenschutz'] as $path) {
|
||||
$page = Page::query()->firstOrCreate(['path' => $path]);
|
||||
$revision = PageRevision::query()->create(['page_id' => $page->id, 'blocks' => [], 'sections' => [], 'seo_title' => ltrim($path, '/')]);
|
||||
$page->published_revision_id = $revision->id;
|
||||
$page->save();
|
||||
}
|
||||
}
|
||||
|
||||
/** Produktion mit Stripe-Live-Schlüssel, aber ohne Freigabe: beide Schalter aus. */
|
||||
private function production(bool $public = false, bool $release = false): void
|
||||
{
|
||||
$this->app['env'] = 'production';
|
||||
config([
|
||||
'services.payment.driver' => 'stripe',
|
||||
'services.stripe.secret' => 'sk_live_nur_fuer_tests',
|
||||
'shop.public' => $public,
|
||||
'shop.live_release' => $release,
|
||||
]);
|
||||
|
||||
if ($release) {
|
||||
$this->publishLegalPages();
|
||||
}
|
||||
}
|
||||
|
||||
/** In Produktion prüft die Anwendung das CSRF-Token (im Testbetrieb wird es sonst übersprungen). */
|
||||
private function postProduction(string $uri, array $data = [], ?User $user = null)
|
||||
{
|
||||
$request = $user === null ? $this : $this->actingAs($user);
|
||||
|
||||
return $request->withSession(['_token' => 'produktion'])->post($uri, $data + ['_token' => 'produktion']);
|
||||
}
|
||||
|
||||
private function articleUrl(): string
|
||||
{
|
||||
return route('shop.article', $this->article('shop-konflikte'));
|
||||
}
|
||||
|
||||
// ---- Der alte Einzelkauf ----------------------------------------------------------------------------------------
|
||||
|
||||
public function test_production_without_release_creates_no_order_through_the_removed_direct_purchase(): void
|
||||
{
|
||||
$this->production();
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
foreach (['/bereich/angebote/'.$offer->id.'/kaufen', '/angebote/'.$offer->id.'/kaufen'] as $path) {
|
||||
$this->postProduction($path, [], $this->tina())->assertStatus(404);
|
||||
}
|
||||
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
$this->assertFalse(Route::has('member.offers.buy'), 'Die Route des Einzelkaufs ist entfernt.');
|
||||
}
|
||||
|
||||
public function test_the_direct_purchase_is_gone_in_test_mode_too_and_checkout_has_no_place_method(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->actingAs($this->tina())->post('/bereich/angebote/'.$offer->id.'/kaufen')->assertStatus(404);
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
$this->assertFalse(method_exists(Checkout::class, 'place'), 'Es gibt nur noch die Bestellung aus dem Warenkorb mit Pflichtangaben.');
|
||||
}
|
||||
|
||||
// ---- Die Schalter -----------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_in_production_both_switches_are_off_by_default_and_nothing_of_the_shop_is_reachable(): void
|
||||
{
|
||||
$this->production();
|
||||
|
||||
$this->assertFalse(Shop::visible());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
$this->get($this->articleUrl())->assertNotFound();
|
||||
$this->get(route('public.package', Bundle::query()->firstOrFail()))->assertNotFound();
|
||||
$this->get(route('cart'))->assertNotFound();
|
||||
$this->get(route('checkout'))->assertNotFound();
|
||||
$this->get(route('shop.closed'))->assertNotFound();
|
||||
$this->postProduction(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
||||
$this->postProduction(route('cart.buy', $this->privateKonflikte()))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_with_the_shop_visible_but_the_checkout_closed_the_shop_can_be_viewed_but_not_bought_from(): void
|
||||
{
|
||||
$this->production(public: true);
|
||||
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
|
||||
$this->get(route('shop'))
|
||||
->assertOk()
|
||||
->assertSee('Konflikte im Training')
|
||||
->assertSee('<meta name="robots" content="noindex, nofollow">', false);
|
||||
|
||||
$page = $this->get($this->articleUrl())->assertOk();
|
||||
$page->assertSee('Privatlizenz')
|
||||
->assertSee('49,00 €')
|
||||
->assertSee('Kaufen')
|
||||
->assertSee(route('shop.closed'), false)
|
||||
->assertDontSee('In den Warenkorb')
|
||||
->assertDontSee('Jetzt kaufen')
|
||||
->assertSee('noindex', false);
|
||||
|
||||
$this->get(route('shop.closed'))
|
||||
->assertOk()
|
||||
->assertSee('noch nicht freigeschaltet')
|
||||
->assertSee('Verkaufsstart')
|
||||
->assertSee('noindex', false)
|
||||
->assertSee(route('shop'), false);
|
||||
}
|
||||
|
||||
public function test_with_the_checkout_closed_cart_checkout_and_buy_now_lead_to_the_notice_and_change_nothing(): void
|
||||
{
|
||||
$this->production(public: true);
|
||||
$offer = $this->privateKonflikte();
|
||||
$member = $this->tina();
|
||||
|
||||
$this->postProduction(route('cart.add', $offer))->assertRedirect(route('shop.closed'));
|
||||
$this->postProduction(route('cart.buy', $offer))->assertRedirect(route('shop.closed'));
|
||||
$this->get(route('cart'))->assertRedirect(route('shop.closed'));
|
||||
$this->get(route('checkout'))->assertRedirect(route('shop.closed'));
|
||||
$this->actingAs($member)->get(route('checkout'))->assertRedirect(route('shop.closed'));
|
||||
$this->postProduction(route('checkout.place'), $this->consentFields() + ['digest' => str_repeat('a', 64)], $member)->assertRedirect(route('shop.closed'));
|
||||
|
||||
$this->assertSame([], app(Cart::class)->items());
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
$this->assertStringNotContainsString('href="'.route('cart').'"', $this->get(route('shop'))->getContent(), 'Das Warenkorb-Symbol bleibt aus.');
|
||||
}
|
||||
|
||||
public function test_with_both_switches_on_the_shop_works_as_before(): void
|
||||
{
|
||||
$this->production(public: true, release: true);
|
||||
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
$this->get($this->articleUrl())->assertOk()->assertSee('In den Warenkorb')->assertSee('Jetzt kaufen')->assertDontSee('noindex', false);
|
||||
$this->postProduction(route('cart.add', $this->privateKonflikte()))->assertRedirect();
|
||||
$this->get(route('cart'))->assertOk()->assertSee('Privatlizenz');
|
||||
$this->get(route('shop.closed'))->assertRedirect(route('shop'));
|
||||
}
|
||||
|
||||
public function test_a_release_alone_makes_the_shop_visible_without_a_second_setting(): void
|
||||
{
|
||||
$this->production(public: false, release: true);
|
||||
|
||||
$this->assertTrue(Shop::visible(), 'Wer den Checkout öffnet, hat den Shop damit sichtbar gemacht.');
|
||||
$this->get(route('shop'))->assertOk();
|
||||
}
|
||||
|
||||
public function test_a_test_or_local_instance_has_both_switches_on_with_the_test_driver_and_off_without_a_driver(): void
|
||||
{
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
|
||||
config(['services.payment.driver' => 'aus']);
|
||||
|
||||
$this->assertFalse(Shop::visible());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_the_stripe_webhook_and_gateway_stay_bound_to_the_live_release_not_to_visibility(): void
|
||||
{
|
||||
$this->production(public: true);
|
||||
|
||||
$this->assertFalse(Shop::stripe());
|
||||
$this->assertFalse(Shop::live());
|
||||
$this->postProduction(route('stripe.webhook'))->assertNotFound();
|
||||
}
|
||||
|
||||
// ---- Menü und alte Adresse --------------------------------------------------------------------------------------
|
||||
|
||||
public function test_the_old_public_offers_address_redirects_to_the_shop_when_the_shop_is_visible(): void
|
||||
{
|
||||
$this->get('/angebote')->assertRedirect(route('shop'));
|
||||
}
|
||||
|
||||
public function test_while_the_shop_is_hidden_an_existing_cms_page_stays_and_without_one_the_address_is_gone(): void
|
||||
{
|
||||
$page = Page::query()->create(['path' => '/angebote']);
|
||||
$revision = PageRevision::query()->create(['page_id' => $page->id, 'blocks' => [], 'sections' => [], 'seo_title' => 'Angebote']);
|
||||
$page->published_revision_id = $revision->id;
|
||||
$page->save();
|
||||
|
||||
$this->production();
|
||||
$this->get('/angebote')->assertOk();
|
||||
|
||||
$page->delete();
|
||||
$this->get('/angebote')->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_menu_entries_pointing_into_the_shop_are_hidden_while_the_shop_is_not_visible(): void
|
||||
{
|
||||
NavigationItem::query()->create(['label' => 'Shopartikel', 'url' => '/shop/4', 'placement' => 'footer', 'sort_order' => 91, 'is_visible' => true]);
|
||||
NavigationItem::query()->create(['label' => 'Warenkorbweg', 'url' => '/warenkorb', 'placement' => 'footer', 'sort_order' => 92, 'is_visible' => true]);
|
||||
$startseite = Page::query()->firstOrCreate(['path' => '/']);
|
||||
$revision = PageRevision::query()->create(['page_id' => $startseite->id, 'blocks' => [], 'sections' => [], 'seo_title' => 'Start']);
|
||||
$startseite->published_revision_id = $revision->id;
|
||||
$startseite->save();
|
||||
|
||||
$this->get('/')->assertOk()->assertSee('href="'.url('/shop').'"', false);
|
||||
|
||||
$this->production();
|
||||
$this->get('/')->assertOk()
|
||||
->assertDontSee('href="'.url('/shop').'"', false)
|
||||
->assertDontSee('href="'.url('/shop/4').'"', false)
|
||||
->assertDontSee('href="'.url('/warenkorb').'"', false);
|
||||
|
||||
$this->production(public: true);
|
||||
$this->get('/')->assertOk()->assertSee('href="'.url('/shop').'"', false);
|
||||
}
|
||||
|
||||
// ---- „Jetzt kaufen“ ---------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_buy_now_puts_the_option_in_the_cart_and_opens_the_order_overview(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $offer))->assertRedirect(route('checkout'));
|
||||
|
||||
$this->assertSame([$offer->id], array_keys(app(Cart::class)->items()));
|
||||
$this->assertSame(0, Order::query()->count(), 'Erst der Knopf „Zahlungspflichtig bestellen“ legt eine Bestellung an.');
|
||||
$this->actingAs($this->tina())->get(route('checkout'))
|
||||
->assertOk()
|
||||
->assertSee('Zahlungspflichtig bestellen')
|
||||
->assertSee('Privatlizenz');
|
||||
}
|
||||
|
||||
public function test_buy_now_replaces_another_option_of_the_same_product_without_asking_and_keeps_other_products(): void
|
||||
{
|
||||
$private = $this->privateKonflikte();
|
||||
$club = $this->clubKonflikte();
|
||||
$other = $this->privateGrenzen();
|
||||
$cart = app(Cart::class);
|
||||
$cart->add($private);
|
||||
$cart->add($other);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $club))->assertRedirect(route('checkout'));
|
||||
|
||||
$ids = array_keys(app(Cart::class)->items());
|
||||
sort($ids);
|
||||
$expected = [$club->id, $other->id];
|
||||
sort($expected);
|
||||
$this->assertSame($expected, $ids);
|
||||
}
|
||||
|
||||
public function test_a_guest_buying_now_is_sent_to_the_login_and_keeps_the_cart(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->post(route('cart.buy', $offer))->assertRedirect(route('checkout'));
|
||||
$this->get(route('checkout'))->assertRedirect(route('login'));
|
||||
$this->assertSame([$offer->id], array_keys(app(Cart::class)->items()));
|
||||
|
||||
$this->post('/anmelden', ['email' => $this->tina()->email, 'password' => ShopDemoSeeder::PASSWORD])->assertRedirect();
|
||||
$this->assertAuthenticatedAs($this->tina());
|
||||
$this->assertSame([$offer->id], array_keys(app(Cart::class)->items()), 'Der Warenkorb übersteht die Anmeldung.');
|
||||
}
|
||||
|
||||
public function test_buy_now_refuses_an_option_that_is_not_for_sale_and_a_missing_one(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
app(OfferService::class)->end($offer);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $offer))->assertRedirect()->assertSessionHasErrors('shop');
|
||||
$this->assertSame([], app(Cart::class)->items());
|
||||
$this->actingAs($this->tina())->post('/warenkorb/999999/jetzt-kaufen')->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_buy_now_is_not_offered_for_an_option_the_account_already_owns_and_does_not_add_it(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
$order = $this->orderOf($this->tina(), [$offer]);
|
||||
app(Checkout::class)->confirmTestPayment($order, 'test-eigen');
|
||||
Mail::fake();
|
||||
|
||||
$page = $this->actingAs($this->tina())->get($this->articleUrl())->assertOk();
|
||||
$page->assertSee('Bereits erworben');
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $offer))->assertRedirect()->assertSessionHas('status');
|
||||
$this->assertSame([], app(Cart::class)->items());
|
||||
}
|
||||
|
||||
// ---- Mitgliederseite „Angebote“ ---------------------------------------------------------------------------------
|
||||
|
||||
private function freeOffer(): Offer
|
||||
{
|
||||
$article = app(ArticleService::class)->create('gratis-artikel');
|
||||
app(ArticleService::class)->publishRelease($article, $this->article('shop-grenzen')->currentRelease->rootCompositionVersion, 'Erster Stand.');
|
||||
$service = app(OfferService::class);
|
||||
$offer = $service->create('Gratis zum Start');
|
||||
$rights = RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Privatlizenz ehrenamtlich'))->firstOrFail();
|
||||
$service->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf', 'holder_kind' => 'person']);
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_offers_only_the_free_claim_and_a_link_to_the_shop_but_no_purchase(): void
|
||||
{
|
||||
$free = $this->freeOffer();
|
||||
|
||||
$page = $this->actingAs($this->tina())->get(route('member.offers'))->assertOk();
|
||||
$page->assertSee('Gratis zum Start')
|
||||
->assertSee('In die Bibliothek')
|
||||
->assertSee(route('shop'), false)
|
||||
->assertDontSee('Testzahlung')
|
||||
->assertDontSee('Kaufen')
|
||||
->assertDontSee('Konflikte im Training: Privatlizenz');
|
||||
$page->assertSee(route('member.offers.claim', $free), false);
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_hides_the_shop_link_while_the_shop_is_not_visible_and_claiming_still_works(): void
|
||||
{
|
||||
$free = $this->freeOffer();
|
||||
$this->production();
|
||||
|
||||
$page = $this->actingAs($this->tina())->get(route('member.offers'))->assertOk();
|
||||
$page->assertSee('Gratis zum Start')->assertDontSee(route('shop'), false);
|
||||
|
||||
$this->postProduction(route('member.offers.claim', $free), [], $this->tina())->assertRedirect(route('member.library'));
|
||||
$this->assertSame(1, Acquisition::query()->where('party_id', $this->tina()->party_id)->count());
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_requires_a_login(): void
|
||||
{
|
||||
$this->get(route('member.offers'))->assertRedirect();
|
||||
}
|
||||
}
|
||||
@@ -39,11 +39,11 @@ protected function setUp(): void
|
||||
|
||||
public function test_stripe_is_a_shop_driver_but_never_in_production(): void
|
||||
{
|
||||
$this->assertTrue(Shop::enabled());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
$this->assertTrue(Shop::stripe());
|
||||
|
||||
$this->app['env'] = 'production';
|
||||
$this->assertFalse(Shop::enabled());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->assertFalse(Shop::stripe());
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ public function test_reordering_the_main_menu_changes_only_that_menu(): void
|
||||
{
|
||||
$footerBefore = NavigationItem::query()->where('placement', 'footer')->orderBy('id')->get(['id', 'sort_order', 'updated_at'])->toArray();
|
||||
$component = $this->menus();
|
||||
$angebote = 'e'.$this->item('Angebote')->id;
|
||||
$angebote = 'e'.$this->item('Shop')->id;
|
||||
|
||||
Carbon::setTestNow(now()->addMinute());
|
||||
$component->call('verschiebe', $angebote, 'hoch')
|
||||
@@ -167,7 +167,7 @@ public function test_reordering_the_main_menu_changes_only_that_menu(): void
|
||||
|
||||
$expected = array_map(fn (array $knoten): string => $component->get("eintraege.{$knoten['k']}.label"), $component->instance()->baum('header'));
|
||||
$public = array_column($this->publicNavigation()->header(), 'label');
|
||||
$this->assertSame(['Start', 'Angebote', 'Prävention', 'Materialien', 'Trainer und Einrichtungen', 'Über das Projekt', 'Anmelden'], $public);
|
||||
$this->assertSame(['Start', 'Shop', 'Prävention', 'Materialien', 'Trainer und Einrichtungen', 'Über das Projekt', 'Anmelden'], $public);
|
||||
$this->assertSame($expected, $public, 'Die öffentliche Reihenfolge entspricht der Liste im Editor.');
|
||||
$this->assertSame($footerBefore, NavigationItem::query()->where('placement', 'footer')->orderBy('id')->get(['id', 'sort_order', 'updated_at'])->toArray(), 'Der Fußbereich bleibt unberührt (WEB-02).');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user