- PM-Detailseite (Entwurf/Ueberarbeiten): ist kein Buchungs-Gate erfuellt,
erscheint statt 'Zur Pruefung einreichen' der Hinweis 'Noch keine Buchung'
mit Link zur Buchungsseite ('Buchung waehlen'). Entwurf speichern bleibt frei.
- phpunit pinnt BILLING_ENFORCE_BOOKING=false, damit der Gate in Tests
deterministisch bleibt (Tests, die ihn brauchen, setzen ihn per config)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
2.4 KiB
PHP
73 lines
2.4 KiB
PHP
<?php
|
|
|
|
use App\Models\Category;
|
|
use App\Models\Company;
|
|
use App\Models\PressRelease;
|
|
use App\Models\SinglePurchase;
|
|
use App\Models\User;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Livewire\Volt\Volt as LivewireVolt;
|
|
use Tests\TestCase;
|
|
|
|
beforeEach(function (): void {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
});
|
|
|
|
function draftForGate(): array
|
|
{
|
|
$customer = User::factory()->create(['is_active' => true]);
|
|
$customer->assignRole('customer');
|
|
|
|
$company = Company::factory()->presseecho()->create();
|
|
$customer->companies()->attach($company->id, ['role' => 'owner']);
|
|
|
|
$pr = PressRelease::factory()->create([
|
|
'user_id' => $customer->id,
|
|
'company_id' => $company->id,
|
|
'category_id' => Category::factory()->create()->id,
|
|
'portal' => $company->portal->value,
|
|
'status' => 'draft',
|
|
]);
|
|
|
|
return compact('customer', 'pr');
|
|
}
|
|
|
|
test('with the gate on a draft without a booking shows the notice and links to bookings', function () {
|
|
/** @var TestCase $this */
|
|
config()->set('billing.enforce_booking', true);
|
|
['customer' => $customer, 'pr' => $pr] = draftForGate();
|
|
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Noch keine Buchung')
|
|
->assertSee('Buchung wählen')
|
|
->assertSee(route('me.bookings.index'), false)
|
|
->assertDontSee('Zur Prüfung einreichen');
|
|
});
|
|
|
|
test('with the gate on a paid single purchase unlocks the submission action', function () {
|
|
/** @var TestCase $this */
|
|
config()->set('billing.enforce_booking', true);
|
|
['customer' => $customer, 'pr' => $pr] = draftForGate();
|
|
SinglePurchase::factory()->paid()->create(['user_id' => $customer->id]);
|
|
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertDontSee('Noch keine Buchung')
|
|
->assertSee('Zur Prüfung einreichen');
|
|
});
|
|
|
|
test('with the gate off the notice never shows', function () {
|
|
/** @var TestCase $this */
|
|
config()->set('billing.enforce_booking', false);
|
|
['customer' => $customer, 'pr' => $pr] = draftForGate();
|
|
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertDontSee('Noch keine Buchung')
|
|
->assertSee('Zur Prüfung einreichen');
|
|
});
|