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,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