Mache den Lizenzartikel zur Produktseite und leite die Seite aus dem Angebot ab
CI Feature / test (push) Failing after 3m16s
CI Feature / test (push) Failing after 3m16s
Die Produktseite ist die Seite des Artikels (/shop/{id}), den die Option als einzige
Position verkauft, oder die Paketseite. Sie wird nicht mehr einem Programm zugeordnet.
Ein Kauf braucht genau eine Position und einen Preis, sonst lässt er sich nicht aktivieren.
Module und Programme werden dadurch nicht öffentlich (Karten und /programme unverändert).
Tests: Die Tests, die eine Programmseite als Produktseite voraussetzten, prüfen jetzt die
Artikelseite; die Zuordnung „eigene Paketseite oder Programmseite“ entfällt (ADR-52).
Ein Altbestandstest sichert die Programmseite für Angebote mit mehreren Positionen.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1950dc377b
commit
08f7d0c63d
22 files changed
+544
-275
No files matched your search
@@ -3,7 +3,6 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Commerce\Cart;
|
||||
@@ -38,7 +37,7 @@ private function standaloneOffer(string $name, int $cents, string $scope = 'einz
|
||||
$rights = app(OfferService::class)->currentActiveVersion($this->privateKonflikte())->lines()->first()->rights;
|
||||
$offers = app(OfferService::class);
|
||||
$offer = $offers->create($name);
|
||||
$offers->assignProduct($offer, null, $name, true);
|
||||
$offers->setOptionLabel($offer, $name);
|
||||
$offers->activate($offer, [['target' => $version, 'rights' => $rights]], [
|
||||
'grant_kind' => 'kauf', 'price_cents' => $cents, 'holder_kind' => 'person', 'licence_scope' => $scope, 'trainer_count' => $trainers,
|
||||
]);
|
||||
@@ -100,30 +99,14 @@ public function test_the_package_page_is_gone_without_a_purchasable_option(): vo
|
||||
$this->get(route('public.package', $this->bundle()))->assertOk();
|
||||
|
||||
app(OfferService::class)->end($offer);
|
||||
$this->get(route('public.package', $this->bundle()))->assertOk(); // Das Demo-Angebot „Starterpaket: Privatlizenz“ verkauft dasselbe Paket weiter.
|
||||
|
||||
app(OfferService::class)->end($this->offerNamed('Starterpaket: Privatlizenz'));
|
||||
|
||||
$this->get(route('public.package', $this->bundle()))->assertNotFound();
|
||||
$this->get(route('shop'))->assertDontSee(route('public.package', $this->bundle()), false);
|
||||
}
|
||||
|
||||
public function test_an_offer_with_an_own_package_page_consists_of_exactly_one_package_version(): void
|
||||
{
|
||||
$offers = app(OfferService::class);
|
||||
$offer = $offers->create('Falsch');
|
||||
$offers->assignProduct($offer, null, 'Falsch', true);
|
||||
$rights = $offers->currentActiveVersion($this->privateKonflikte())->lines()->first()->rights;
|
||||
|
||||
$this->expectException(DomainRuleException::class);
|
||||
$offers->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $rights]], ['grant_kind' => 'kauf', 'price_cents' => 1000]);
|
||||
}
|
||||
|
||||
public function test_a_package_has_either_an_own_page_or_a_program_page(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Beides');
|
||||
|
||||
$this->expectException(DomainRuleException::class);
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Konflikte im Training')->id, 'Beides', true);
|
||||
}
|
||||
|
||||
public function test_the_package_page_does_not_exist_outside_the_shop(): void
|
||||
{
|
||||
$this->standaloneOffer('Starterpaket solo', 5500);
|
||||
|
||||
@@ -407,18 +407,50 @@ public function test_the_checkout_says_so_when_no_holder_is_allowed(): void
|
||||
->assertDontSee('Alle Positionen sind bereits erworben');
|
||||
}
|
||||
|
||||
public function test_only_options_with_a_public_product_page_can_be_put_into_the_cart(): void
|
||||
public function test_only_purchasable_options_can_be_put_into_the_cart(): void
|
||||
{
|
||||
$this->privateGrenzen()->update(['composition_id' => null]);
|
||||
$this->post(route('cart.add', $this->privateGrenzen()))->assertSessionHasErrors('shop');
|
||||
app(OfferService::class)->end($this->privateGrenzen());
|
||||
|
||||
$this->post(route('cart.add', $this->privateGrenzen()))->assertSessionHasErrors('shop');
|
||||
$this->assertSame(0, app(Cart::class)->count());
|
||||
}
|
||||
|
||||
public function test_alternatives_are_the_options_of_one_article_and_not_those_of_different_articles(): void
|
||||
{
|
||||
$cart = app(Cart::class);
|
||||
$this->assertSame(Cart::ADDED, $cart->add($this->privateKonflikte()));
|
||||
|
||||
$this->assertSame(Cart::ALTERNATIVE, $cart->add($this->clubKonflikte()), 'Zwei Optionen desselben Artikels sind Alternativen.');
|
||||
$this->assertSame(Cart::ADDED, $cart->add($this->privateGrenzen()), 'Ein anderer Artikel liegt zusätzlich im Warenkorb.');
|
||||
$this->assertSame(2, $cart->count());
|
||||
}
|
||||
|
||||
public function test_a_legacy_offer_with_several_positions_stays_on_its_program_page_while_that_is_shown(): void
|
||||
{
|
||||
$program = $this->program('Konflikte im Training');
|
||||
$rights = app(OfferService::class)->currentActiveVersion($this->privateKonflikte())->lines()->first()->rights;
|
||||
$offer = app(OfferService::class)->create('Altbestand');
|
||||
app(OfferService::class)->activate($offer, [
|
||||
['target' => $this->article('shop-konflikte'), 'rights' => $rights],
|
||||
['target' => $this->article('shop-grenzen'), 'rights' => $rights],
|
||||
], ['grant_kind' => 'auf_abruf', 'holder_kind' => 'person']);
|
||||
// So steht ein früher als Kauf aktivierter Altbestand in der Datenbank: mehrere Positionen, Programmseite.
|
||||
DB::table('offer_versions')->where('offer_id', $offer->id)->update(['grant_kind' => 'kauf', 'price_cents' => 1000]);
|
||||
DB::table('offers')->where('id', $offer->id)->update(['composition_id' => $program->id, 'option_label' => 'Altbestand']);
|
||||
$offer = $offer->refresh();
|
||||
|
||||
$this->assertSame('c:'.$program->id, app(ProductOptions::class)->groupKey($offer));
|
||||
$this->get(route('public.program', $program))->assertOk()->assertSee('Altbestand');
|
||||
$this->post(route('cart.add', $offer))->assertSessionDoesntHaveErrors();
|
||||
$this->assertSame(1, app(Cart::class)->count());
|
||||
|
||||
app(Cart::class)->clear();
|
||||
$program->versions()->each(fn ($version) => $version->displayEvents()->create([
|
||||
'event' => CompositionVersionDisplayEvent::REVOKED,
|
||||
'actor_id' => $this->tina()->id,
|
||||
'occurred_at' => now()->addSecond(),
|
||||
]));
|
||||
$this->post(route('cart.add', $this->privateKonflikte()))->assertSessionHasErrors('shop');
|
||||
$this->post(route('cart.add', $offer))->assertSessionHasErrors('shop');
|
||||
$this->assertSame(0, app(Cart::class)->count());
|
||||
}
|
||||
|
||||
|
||||
@@ -102,10 +102,10 @@ public function test_the_scope_is_not_derived_from_purpose_price_or_discount():
|
||||
|
||||
public function test_the_product_page_tells_single_and_multi_licenses_apart(): void
|
||||
{
|
||||
$page = $this->program('Konflikte im Training');
|
||||
$page = $this->article('shop-konflikte');
|
||||
$this->variant($this->privateKonflikte(), 'Ohne Angabe', ['price_cents' => 1900]);
|
||||
|
||||
$this->get(route('public.program', $page))
|
||||
$this->get(route('shop.article', $page))
|
||||
->assertOk()
|
||||
->assertSee('Nutzerkreis')
|
||||
->assertSee('Einzellizenz · 1 Trainer')
|
||||
|
||||
@@ -40,7 +40,7 @@ public function test_the_option_page_shows_price_in_euro_suitability_rights_cont
|
||||
->assertSee('Ehrenamtlich: Film ansehen, Film herunterladen, PDF ansehen, PDF herunterladen')
|
||||
->assertSee('Zugrunde liegender Inhalt: Konflikte im Training')
|
||||
->assertSee('Status: Öffentlich kaufbar')
|
||||
->assertSee('Produktseite: Konflikte im Training')
|
||||
->assertSee('Produktseite: öffentlich unter /shop/'.$this->article('shop-konflikte')->id)
|
||||
->assertSee('Geänderte Fassung aktivieren')
|
||||
->assertSee('Aus dem Verkauf nehmen');
|
||||
|
||||
|
||||
@@ -32,16 +32,17 @@ public function test_the_shop_lists_products_with_the_lowest_price_and_opens_the
|
||||
->assertSee('2 Lizenzoptionen')
|
||||
->assertSee('ab 29,00 €')
|
||||
->assertSee('3 Produkte');
|
||||
$page->assertSee(route('public.program', $this->program('Konflikte im Training')), false);
|
||||
$page->assertSee(route('shop.article', $this->article('shop-konflikte')), false);
|
||||
}
|
||||
|
||||
public function test_the_shop_search_filters_and_shows_an_empty_state(): void
|
||||
{
|
||||
$this->get(route('shop', ['suche' => 'Grenzen']))
|
||||
->assertOk()
|
||||
->assertSee('Grenzen setzen im Verein')
|
||||
->assertDontSee('Konflikte im Training')
|
||||
->assertSee('1 Produkt');
|
||||
->assertSee(route('shop.article', $this->article('shop-grenzen')), false)
|
||||
->assertDontSee(route('shop.article', $this->article('shop-konflikte')), false)
|
||||
->assertSee('Paket mit 3 Inhalten', false)
|
||||
->assertSee('2 Produkte');
|
||||
|
||||
$this->get(route('shop', ['suche' => 'gibt-es-nicht']))
|
||||
->assertOk()
|
||||
@@ -51,7 +52,7 @@ public function test_the_shop_search_filters_and_shows_an_empty_state(): void
|
||||
|
||||
public function test_the_product_page_shows_content_and_options_with_price_rights_and_term(): void
|
||||
{
|
||||
$response = $this->get(route('public.program', $this->program('Konflikte im Training')))->assertOk();
|
||||
$response = $this->get(route('shop.article', $this->article('shop-konflikte')))->assertOk();
|
||||
|
||||
$response->assertSee('Konflikte erkennen, benennen und gemeinsam lösen.')
|
||||
->assertSee('Film: Film Konflikte im Training')
|
||||
@@ -74,7 +75,7 @@ public function test_a_withdrawn_option_disappears_while_the_other_options_stay_
|
||||
{
|
||||
app(OfferService::class)->end($this->privateKonflikte());
|
||||
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
$this->get(route('shop.article', $this->article('shop-konflikte')))
|
||||
->assertOk()
|
||||
->assertDontSee('Privatlizenz')
|
||||
->assertSee('Mehrfachlizenz für Vereine')
|
||||
@@ -87,9 +88,9 @@ public function test_free_and_unpriced_offers_are_not_shown_as_purchasable(): vo
|
||||
$article = $this->article('shop-konflikte');
|
||||
$rights = app(OfferService::class)->createRightsProfile('Frei', 'ehrenamtlich', ['pdf' => ['ansehen']]);
|
||||
app(OfferService::class)->activate($free, [['target' => $article, 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
||||
app(OfferService::class)->assignProduct($free, $this->program('Konflikte im Training')->id, 'Kostenlos testen');
|
||||
app(OfferService::class)->setOptionLabel($free, 'Kostenlos testen');
|
||||
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
$this->get(route('shop.article', $this->article('shop-konflikte')))
|
||||
->assertOk()
|
||||
->assertDontSee('Kostenlos testen');
|
||||
}
|
||||
@@ -103,10 +104,12 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
$this->get(route('cart'))->assertNotFound();
|
||||
$this->post(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
||||
$this->get(route('shop.article', $this->article('shop-konflikte')))->assertNotFound();
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
->assertOk()
|
||||
->assertDontSee('Lizenzoptionen')
|
||||
->assertDontSee('In den Warenkorb');
|
||||
->assertDontSee('In den Warenkorb')
|
||||
->assertDontSee('Zum Kaufen');
|
||||
|
||||
config(['services.payment.driver' => 'test']);
|
||||
$this->app['env'] = 'production';
|
||||
@@ -114,13 +117,62 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_an_option_without_a_product_page_is_not_listed_in_the_shop(): void
|
||||
public function test_an_article_without_a_purchasable_option_has_no_page_and_is_not_listed(): void
|
||||
{
|
||||
$this->privateGrenzen()->update(['composition_id' => null]);
|
||||
$page = route('shop.article', $this->article('shop-grenzen'), false);
|
||||
$this->get($page)->assertOk();
|
||||
$this->get(route('shop'))->assertSee($page, false);
|
||||
|
||||
$this->get(route('shop'))
|
||||
->assertOk()
|
||||
->assertDontSee('Grenzen setzen im Verein')
|
||||
->assertSee('Konflikte im Training');
|
||||
app(OfferService::class)->end($this->privateGrenzen());
|
||||
|
||||
$this->get($page)->assertNotFound();
|
||||
$this->get(route('shop'))->assertOk()->assertDontSee($page, false)->assertSee('Konflikte im Training');
|
||||
}
|
||||
|
||||
public function test_the_product_page_of_an_article_takes_its_texts_from_the_article_and_otherwise_from_its_content(): void
|
||||
{
|
||||
$article = $this->article('shop-konflikte');
|
||||
|
||||
// Ohne eigene Angabe kommt die Beschreibung aus der Redaktion des Inhalts (der Komposition).
|
||||
$this->get(route('shop.article', $article))->assertOk()
|
||||
->assertSee('Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.')
|
||||
->assertSee('Konflikte erkennen, benennen und gemeinsam lösen.');
|
||||
|
||||
// Eine eigene Angabe des Artikels überschreibt sie, ohne den Inhalt zu ändern.
|
||||
$article->forceFill(['display_title' => 'Konflikte meistern', 'summary' => 'Eigene Beschreibung des Artikels.'])->save();
|
||||
$this->get(route('shop.article', $article))->assertOk()
|
||||
->assertSee('<h1>Konflikte meistern</h1>', false)
|
||||
->assertSee('Eigene Beschreibung des Artikels.')
|
||||
->assertDontSee('Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.');
|
||||
}
|
||||
|
||||
public function test_the_article_page_shows_titles_and_structure_but_no_files_or_teaching_texts(): void
|
||||
{
|
||||
$html = $this->get(route('shop.article', $this->article('shop-konflikte')))->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('Film: Film Konflikte im Training', $html);
|
||||
$this->assertStringNotContainsString('inhalte/shop-konflikte', $html, 'Dateipfade gehören nicht auf die öffentliche Seite.');
|
||||
$this->assertStringNotContainsString('film.mp4', $html);
|
||||
$this->assertStringNotContainsString('Platzhalter', $html, 'Der Inhalt der Dateien erscheint nicht.');
|
||||
$this->assertStringNotContainsString('/bereich/', $html, 'Kein Verweis in die Mitgliederbibliothek.');
|
||||
}
|
||||
|
||||
public function test_the_program_page_links_to_the_article_pages_instead_of_showing_options(): void
|
||||
{
|
||||
$program = $this->program('Konflikte im Training');
|
||||
|
||||
$this->get(route('public.program', $program))->assertOk()
|
||||
->assertSee('Zum Kaufen')
|
||||
->assertSee(route('shop.article', $this->article('shop-konflikte')), false)
|
||||
->assertDontSee('Umfang und Nutzungsrechte')
|
||||
->assertDontSee('In den Warenkorb');
|
||||
}
|
||||
|
||||
public function test_a_module_is_not_public_through_the_shop_page_of_its_article_unless_it_is_sold(): void
|
||||
{
|
||||
// Ohne kaufbare Option ist ein Artikel, auch mit veröffentlichtem Stand, nirgends öffentlich.
|
||||
$article = $this->article('shop-starter');
|
||||
$this->get(route('shop.article', $article))->assertNotFound();
|
||||
$this->get(route('shop.article', 999999))->assertNotFound();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
@@ -161,28 +162,21 @@ public function test_the_offer_page_walks_from_empty_to_findable_in_the_shop():
|
||||
$offer = app(OfferService::class)->create('Neues Angebot');
|
||||
$readiness = app(PublicationReadiness::class);
|
||||
$page = fn () => Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()]);
|
||||
$article = $this->article('shop-konflikte');
|
||||
|
||||
$page()->assertSee('Bis zur Veröffentlichung')->assertSeeText('Nächster Schritt: Artikel oder Paket, Rechte, Preis und Vergabe festlegen');
|
||||
$this->assertFalse($readiness->forOffer($offer->refresh())['bereit']);
|
||||
$this->assertNull(app(ProductOptions::class)->pageUrl($offer));
|
||||
|
||||
// Aktiv, aber ohne Produktseite: nicht im Shop.
|
||||
app(OfferService::class)->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$page()->assertSeeText('Nächster Schritt: Produktseite zuordnen');
|
||||
$this->assertSame('Produktseite zuordnen', $readiness->forOffer($offer->refresh())['naechster']['titel']);
|
||||
|
||||
// Zugeordnet, aber Programm ohne Anzeigefreigabe: nicht auffindbar.
|
||||
$hidden = $this->hiddenProgram();
|
||||
app(OfferService::class)->assignProduct($offer, $hidden->id, 'Testoption');
|
||||
$check = $readiness->forOffer($offer->refresh());
|
||||
$this->assertSame('Produktseite öffentlich', $check['naechster']['titel']);
|
||||
$this->get('/shop')->assertOk()->assertDontSee('Testoption');
|
||||
|
||||
// Öffentliche Produktseite: bereit und im Shop.
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Konflikte im Training')->id, 'Testoption');
|
||||
// Mit der aktiven Fassung hat die Option ihre Produktseite: die Seite des Artikels, ohne dass sie zugeordnet wird.
|
||||
app(OfferService::class)->activate($offer, [['target' => $article, 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
app(OfferService::class)->setOptionLabel($offer, 'Testoption');
|
||||
$check = $readiness->forOffer($offer->refresh());
|
||||
$this->assertTrue($check['bereit']);
|
||||
$page()->assertSeeText('Alle Voraussetzungen sind erfüllt.');
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training'), false))->assertOk()->assertSee('Testoption')->assertSee('39,00');
|
||||
$this->assertSame(route('shop.article', $article), app(ProductOptions::class)->pageUrl($offer));
|
||||
$page()->assertSeeText('Alle Voraussetzungen sind erfüllt.')->assertSee('öffentlich unter /shop/'.$article->id);
|
||||
$this->get(route('shop.article', $article))->assertOk()->assertSee('Testoption')->assertSee('39,00');
|
||||
$this->get('/shop')->assertOk()->assertSee(route('shop.article', $article), false);
|
||||
}
|
||||
|
||||
public function test_the_bundle_page_shows_the_steps_and_the_offer_for_the_bundle(): void
|
||||
@@ -203,9 +197,13 @@ public function test_the_bundle_page_shows_the_steps_and_the_offer_for_the_bundl
|
||||
|
||||
public function test_the_bundle_offer_lists_the_scope_and_is_found_in_the_shop(): void
|
||||
{
|
||||
$starter = $this->program('Starterpaket für neue Trainer');
|
||||
$this->get('/shop')->assertOk()->assertSee('Starterpaket für neue Trainer');
|
||||
$this->get(route('public.program', $starter, false))->assertOk()->assertSee('Starterpaket (zwei Programme und Einführung)')->assertSee('59,00');
|
||||
$bundle = Bundle::query()->where('name', 'Starterpaket')->firstOrFail();
|
||||
|
||||
$this->get('/shop')->assertOk()->assertSee(route('public.package', $bundle), false)->assertSee('Paket mit 3 Inhalten');
|
||||
$this->get(route('public.package', $bundle, false))->assertOk()
|
||||
->assertSee('Starterpaket (zwei Programme und Einführung)')
|
||||
->assertSee('Starterpaket für neue Trainer')
|
||||
->assertSee('59,00');
|
||||
}
|
||||
|
||||
public function test_the_scope_names_an_article_by_its_content_and_not_by_its_code(): void
|
||||
@@ -215,12 +213,12 @@ public function test_the_scope_names_an_article_by_its_content_and_not_by_its_co
|
||||
app(ArticleService::class)->publishRelease($article, $root, 'Erster Stand dieses Lizenzartikels.');
|
||||
$offer = app(OfferService::class)->create('Namensprobe');
|
||||
app(OfferService::class)->activate($offer, [['target' => $article->refresh(), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 1500, 'holder_kind' => 'person']);
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Grenzen setzen im Verein')->id, 'Namensprobe');
|
||||
app(OfferService::class)->setOptionLabel($offer, 'Namensprobe');
|
||||
|
||||
$scope = collect(app(ProductOptions::class)->forComposition($this->program('Grenzen setzen im Verein')))->firstWhere('name', 'Namensprobe')['scope'];
|
||||
$scope = collect(app(ProductOptions::class)->forArticle($article))->firstWhere('name', 'Namensprobe')['scope'];
|
||||
|
||||
$this->assertSame('Grenzen setzen im Verein', $scope[0]['article']);
|
||||
$this->get(route('public.program', $this->program('Grenzen setzen im Verein'), false))->assertOk()->assertDontSee('nur-kennung-abnahme');
|
||||
$this->get(route('shop.article', $article))->assertOk()->assertDontSee('nur-kennung-abnahme');
|
||||
$this->assertStringContainsString('Grenzen setzen im Verein (nur-kennung-abnahme) · Stand 1', app(PublicationReadiness::class)->articleOptions()[$article->id]);
|
||||
}
|
||||
|
||||
@@ -241,39 +239,54 @@ private function rights(): RightsProfileVersion
|
||||
return RightsProfileVersion::query()->orderBy('id')->firstOrFail();
|
||||
}
|
||||
|
||||
public function test_the_product_page_choices_say_which_ones_the_shop_can_show(): void
|
||||
public function test_a_purchase_with_several_positions_is_refused_and_points_to_the_package(): void
|
||||
{
|
||||
$hidden = $this->hiddenProgram();
|
||||
$module = app(ContentService::class)->createComposition('Bündel-Modul');
|
||||
$module->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'modul')->value('id');
|
||||
$module->save();
|
||||
|
||||
$method = new \ReflectionMethod(ViewOffer::class, 'productPages');
|
||||
$choices = $method->invoke(app(ViewOffer::class));
|
||||
|
||||
$this->assertStringContainsString('nur für ein Angebot aus genau einer Paketfassung', $choices['__paket']);
|
||||
$this->assertStringContainsString('im Shop auffindbar', $choices[$this->program('Konflikte im Training')->id]);
|
||||
$this->assertStringContainsString('noch nicht zur Anzeige freigegeben', $choices[$hidden->id]);
|
||||
$this->assertStringContainsString('kein Programm', $choices[$module->id]);
|
||||
$this->assertStringContainsString('nur Programme', $choices[$module->id]);
|
||||
}
|
||||
|
||||
public function test_an_own_bundle_page_for_a_licence_article_is_refused_with_the_way_forward(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Bündel als Artikel');
|
||||
app(OfferService::class)->assignProduct($offer, null, null, true);
|
||||
$offer = app(OfferService::class)->create('Mehrere Artikel');
|
||||
$positions = [
|
||||
['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()],
|
||||
['target' => $this->article('shop-grenzen'), 'rights' => $this->rights()],
|
||||
];
|
||||
|
||||
try {
|
||||
app(OfferService::class)->activate($offer->refresh(), [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$this->fail('Ein Lizenzartikel darf keine eigene Paketseite bekommen.');
|
||||
app(OfferService::class)->activate($offer, $positions, ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$this->fail('Ein Kauf mit mehreren Positionen hätte keine Produktseite.');
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->assertStringContainsString('Katalog → Pakete', $e->getMessage());
|
||||
$this->assertStringContainsString('Programm', $e->getMessage());
|
||||
$this->assertStringContainsString('Paket', $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count());
|
||||
}
|
||||
|
||||
public function test_a_purchase_without_a_price_cannot_be_activated(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Ohne Preis');
|
||||
|
||||
foreach ([null, 0] as $price) {
|
||||
try {
|
||||
app(OfferService::class)->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => $price, 'holder_kind' => 'person']);
|
||||
$this->fail('Ein Kauf ohne Preis ist nicht kaufbar.');
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->assertStringContainsString('Preis', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count());
|
||||
}
|
||||
|
||||
public function test_grants_at_registration_and_on_demand_stay_possible_but_are_not_in_the_shop(): void
|
||||
{
|
||||
foreach (['bei_registrierung', 'auf_abruf'] as $kind) {
|
||||
$offer = app(OfferService::class)->create('Ohne Shop '.$kind);
|
||||
app(OfferService::class)->activate($offer, [
|
||||
['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()],
|
||||
['target' => $this->article('shop-grenzen'), 'rights' => $this->rights()],
|
||||
], ['grant_kind' => $kind, 'holder_kind' => 'person']);
|
||||
|
||||
$this->assertNull(app(OfferService::class)->purchasableVersion($offer->refresh()));
|
||||
$this->assertNull(app(ProductOptions::class)->pageUrl($offer));
|
||||
}
|
||||
}
|
||||
|
||||
private function hiddenProgram(): Composition
|
||||
{
|
||||
$composition = app(ContentService::class)->createComposition('Unveröffentlichtes Programm');
|
||||
|
||||
Reference in new issue
Block a user