Gebuendelt, da ueber gemeinsame lang-/Service-Dateien verschraenkt: - Kontakt-Nachrichten: contact_messages-Tabelle + Model/Enums/Factory, Admin-Queue (livewire/admin/contact-messages), ContactController persistiert das Anliegen zusaetzlich zur Brand-Mail - Page-Data-Cache (Services/Web/*PageData) + web-archive-Indizes auf press_releases - Validierungs-Feedback + Company-Portal-Restriction (Feature-Tests) - i18n-Auslagerung lang/de|en (auth, passwords, validation, static) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
97 lines
3.2 KiB
PHP
97 lines
3.2 KiB
PHP
<?php
|
|
|
|
use App\Enums\Portal;
|
|
use App\Models\Company;
|
|
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 makeAdminForPortalRestriction(): User
|
|
{
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
|
|
return $admin;
|
|
}
|
|
|
|
test('Admin-Anlage lehnt Portal Both ab', function () {
|
|
/** @var TestCase $this */
|
|
$this->actingAs(makeAdminForPortalRestriction());
|
|
|
|
LivewireVolt::test('admin.companies.create')
|
|
->set('company_name', 'Beide Portale GmbH')
|
|
->set('email', 'kontakt@beide.de')
|
|
->set('portal', Portal::Both->value)
|
|
->call('save')
|
|
->assertHasErrors(['portal']);
|
|
|
|
expect(Company::query()->withoutGlobalScopes()->where('name', 'Beide Portale GmbH')->exists())
|
|
->toBeFalse();
|
|
});
|
|
|
|
test('Admin-Anlage bietet Beide Portale nicht an und legt Firma mit Einzelportal an', function () {
|
|
/** @var TestCase $this */
|
|
$this->actingAs(makeAdminForPortalRestriction());
|
|
|
|
LivewireVolt::test('admin.companies.create')
|
|
->assertDontSeeText(Portal::Both->label())
|
|
->set('company_name', 'Einzelportal GmbH')
|
|
->set('email', 'kontakt@einzel.de')
|
|
->set('portal', Portal::Businessportal24->value)
|
|
->call('save')
|
|
->assertHasNoErrors()
|
|
->assertRedirect(route('admin.companies.index'));
|
|
|
|
expect(Company::query()->withoutGlobalScopes()->where('name', 'Einzelportal GmbH')->value('portal'))
|
|
->toBe(Portal::Businessportal24);
|
|
});
|
|
|
|
test('Admin-Bearbeitung lehnt Wechsel auf Portal Both ab', function () {
|
|
/** @var TestCase $this */
|
|
$this->actingAs(makeAdminForPortalRestriction());
|
|
|
|
$company = Company::factory()->presseecho()->create();
|
|
|
|
LivewireVolt::test('admin.companies.edit', ['id' => $company->id])
|
|
->assertDontSeeText(Portal::Both->label())
|
|
->set('portal', Portal::Both->value)
|
|
->call('update')
|
|
->assertHasErrors(['portal']);
|
|
|
|
expect($company->fresh()->portal)->toBe(Portal::Presseecho);
|
|
});
|
|
|
|
test('Admin-Bearbeitung erlaubt Bestandsfirmen mit Portal Both den Wert zu behalten', function () {
|
|
/** @var TestCase $this */
|
|
$this->actingAs(makeAdminForPortalRestriction());
|
|
|
|
$company = Company::factory()->create(['portal' => Portal::Both->value]);
|
|
|
|
LivewireVolt::test('admin.companies.edit', ['id' => $company->id])
|
|
->assertSeeText(Portal::Both->label())
|
|
->set('company_name', $company->name)
|
|
->call('update')
|
|
->assertHasNoErrors();
|
|
|
|
expect($company->fresh()->portal)->toBe(Portal::Both);
|
|
});
|
|
|
|
test('Admin-Bearbeitung erlaubt Bestandsfirmen den Wechsel von Both auf ein Einzelportal', function () {
|
|
/** @var TestCase $this */
|
|
$this->actingAs(makeAdminForPortalRestriction());
|
|
|
|
$company = Company::factory()->create(['portal' => Portal::Both->value]);
|
|
|
|
LivewireVolt::test('admin.companies.edit', ['id' => $company->id])
|
|
->set('portal', Portal::Presseecho->value)
|
|
->call('update')
|
|
->assertHasNoErrors();
|
|
|
|
expect($company->fresh()->portal)->toBe(Portal::Presseecho);
|
|
});
|