- 83 Komponenten: Livewire\Volt\Component → Livewire\Component
- 73 Routen (admin, auth, customer): Volt::route() → Route::livewire()
- 88 Testdateien: Volt::test/actingAs → Livewire::test/actingAs
- VoltServiceProvider gelöscht; composer remove livewire/volt
- config/livewire.php auf v4-Schlüssel (component_layout, component_placeholder,
component_locations, make_command: SFC ohne ⚡). Der alte Schlüssel layout war
wirkungslos; alle gerouteten Komponenten setzen ihr Layout selbst.
- CLAUDE.md, AGENTS.md, boost.json, .cursorrules, Skill volt-development
- Roadmap: erledigt; Larastan erfasst SFCs weiterhin nicht (Blade-Dateien)
Suite 2.325 grün, einer übersprungen; Larastan und Pint ohne Meldung;
route:cache und view:cache laufen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
117 lines
3.7 KiB
PHP
117 lines
3.7 KiB
PHP
<?php
|
|
|
|
use App\Enums\Portal;
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
beforeEach(function (): void {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
});
|
|
|
|
function makeCustomerForCreate(): User
|
|
{
|
|
$customer = User::factory()->create(['is_active' => true]);
|
|
$customer->assignRole('customer');
|
|
|
|
return $customer;
|
|
}
|
|
|
|
test('Create-Route ist für eingeloggte Customer erreichbar', function () {
|
|
/** @var TestCase $this */
|
|
$customer = makeCustomerForCreate();
|
|
|
|
$this->actingAs($customer)
|
|
->get('/admin/me/firmen/anlegen')
|
|
->assertOk()
|
|
->assertSeeText('Neue Firma anlegen')
|
|
->assertSeeText('Firmenname');
|
|
});
|
|
|
|
test('Create-Route ist für Gäste nicht zugänglich', function () {
|
|
/** @var TestCase $this */
|
|
$this->get('/admin/me/firmen/anlegen')
|
|
->assertRedirect();
|
|
});
|
|
|
|
test('save erstellt eine Firma und ordnet sie dem User als Owner zu', function () {
|
|
/** @var TestCase $this */
|
|
$customer = makeCustomerForCreate();
|
|
|
|
Livewire::actingAs($customer)
|
|
->test('customer.press-kits.create')
|
|
->set('name', 'Neue Brauerei AG')
|
|
->set('portal', 'presseecho')
|
|
->set('email', 'kontakt@brauerei.de')
|
|
->call('save')
|
|
->assertHasNoErrors()
|
|
->assertRedirect();
|
|
|
|
/** @var Company $company */
|
|
$company = Company::query()->withoutGlobalScopes()->where('name', 'Neue Brauerei AG')->first();
|
|
|
|
expect($company)->not->toBeNull()
|
|
->and($company->owner_user_id)->toBe($customer->id)
|
|
->and($company->portal->value)->toBe('presseecho')
|
|
// Ohne Typ-Feld immer Newsroom: der Übermittler („Agentur") lebt
|
|
// seit dem Attributions-Umbau im Profilfeld users.agency_name.
|
|
->and($company->type?->value)->toBe('company')
|
|
->and($company->email)->toBe('kontakt@brauerei.de')
|
|
->and($company->is_active)->toBeTrue();
|
|
|
|
expect($customer->companies()->where('companies.id', $company->id)->wherePivot('role', 'owner')->exists())
|
|
->toBeTrue();
|
|
});
|
|
|
|
test('save validiert Pflichtfelder Name und Portal', function () {
|
|
/** @var TestCase $this */
|
|
$customer = makeCustomerForCreate();
|
|
|
|
Livewire::actingAs($customer)
|
|
->test('customer.press-kits.create')
|
|
->set('name', '')
|
|
->set('portal', '')
|
|
->call('save')
|
|
->assertHasErrors(['name' => 'required', 'portal' => 'required']);
|
|
});
|
|
|
|
test('save lehnt unbekannte Portal-Werte ab', function () {
|
|
/** @var TestCase $this */
|
|
$customer = makeCustomerForCreate();
|
|
|
|
Livewire::actingAs($customer)
|
|
->test('customer.press-kits.create')
|
|
->set('name', 'Test GmbH')
|
|
->set('portal', 'invalid')
|
|
->call('save')
|
|
->assertHasErrors(['portal']);
|
|
});
|
|
|
|
test('save lehnt Portal Both ab', function () {
|
|
/** @var TestCase $this */
|
|
$customer = makeCustomerForCreate();
|
|
|
|
Livewire::actingAs($customer)
|
|
->test('customer.press-kits.create')
|
|
->set('name', 'Beide Portale GmbH')
|
|
->set('portal', Portal::Both->value)
|
|
->call('save')
|
|
->assertHasErrors(['portal']);
|
|
|
|
expect(Company::query()->withoutGlobalScopes()->where('name', 'Beide Portale GmbH')->exists())
|
|
->toBeFalse();
|
|
});
|
|
|
|
test('Portal-Auswahl bietet Beide Portale nicht an', function () {
|
|
/** @var TestCase $this */
|
|
$customer = makeCustomerForCreate();
|
|
|
|
Livewire::actingAs($customer)
|
|
->test('customer.press-kits.create')
|
|
->assertSeeText(Portal::Presseecho->label())
|
|
->assertSeeText(Portal::Businessportal24->label())
|
|
->assertDontSeeText(Portal::Both->label());
|
|
});
|