- 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>
106 lines
4.1 KiB
PHP
106 lines
4.1 KiB
PHP
<?php
|
|
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use App\Services\Image\ImageService;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Illuminate\Filesystem\FilesystemAdapter;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Logo-Tausch: erst die neue Datei speichern, dann die DB-Referenz wechseln,
|
|
* dann erst das alte Logo löschen. Ein Storage-Fehler darf weder Erfolg
|
|
* vortäuschen noch das bisherige Logo kosten (F23).
|
|
*/
|
|
beforeEach(function (): void {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
});
|
|
|
|
function failingPublicDisk(): FilesystemAdapter
|
|
{
|
|
$disk = Storage::fake('public');
|
|
|
|
// Proxy auf den echten Fake: nur put() schlägt fehl, alles andere —
|
|
// exists(), delete(), Livewires Temp-Upload — läuft echt.
|
|
$failingDisk = Mockery::mock($disk);
|
|
$failingDisk->shouldReceive('put')->andReturn(false);
|
|
Storage::set('public', $failingDisk);
|
|
|
|
return $disk;
|
|
}
|
|
|
|
test('the image service refuses to report a logo that was not written', function () {
|
|
/** @var TestCase $this */
|
|
failingPublicDisk();
|
|
|
|
expect(fn () => app(ImageService::class)->storeCompanyLogo(UploadedFile::fake()->image('logo.png', 400, 400), 'presseecho', 1))
|
|
->toThrow(RuntimeException::class, 'Das Logo konnte nicht gespeichert werden.');
|
|
});
|
|
|
|
test('the image service refuses to report a press release image that was not written', function () {
|
|
/** @var TestCase $this */
|
|
failingPublicDisk();
|
|
|
|
expect(fn () => app(ImageService::class)->storePressReleaseImage(UploadedFile::fake()->image('bild.jpg', 800, 600), 1, 'public'))
|
|
->toThrow(RuntimeException::class, 'Das Bild konnte nicht gespeichert werden.');
|
|
});
|
|
|
|
test('a failed logo write in the admin form keeps the previous logo and reports a validation error', function () {
|
|
/** @var TestCase $this */
|
|
$disk = failingPublicDisk();
|
|
$disk->put('company-logos/presseecho/9/alt.png', 'alt');
|
|
$disk->put('company-logos/presseecho/9/alt-sq.png', 'alt-sq');
|
|
|
|
$company = Company::factory()->presseecho()->create([
|
|
'logo_path' => 'company-logos/presseecho/9/alt.png',
|
|
'logo_variants' => ['sq' => 'company-logos/presseecho/9/alt-sq.png'],
|
|
]);
|
|
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
|
|
Livewire::actingAs($admin)
|
|
->test('admin.companies.edit', ['id' => $company->id])
|
|
->set('logo', UploadedFile::fake()->image('neu.png', 400, 400))
|
|
->call('update')
|
|
->assertHasErrors(['logo']);
|
|
|
|
$company->refresh();
|
|
|
|
expect($company->logo_path)->toBe('company-logos/presseecho/9/alt.png')
|
|
->and($company->logo_variants)->toBe(['sq' => 'company-logos/presseecho/9/alt-sq.png'])
|
|
->and($disk->exists('company-logos/presseecho/9/alt.png'))->toBeTrue()
|
|
->and($disk->exists('company-logos/presseecho/9/alt-sq.png'))->toBeTrue();
|
|
});
|
|
|
|
test('a successful logo replacement in the admin form removes the previous files only afterwards', function () {
|
|
/** @var TestCase $this */
|
|
$disk = Storage::fake('public');
|
|
$disk->put('company-logos/presseecho/9/alt.png', 'alt');
|
|
$disk->put('company-logos/presseecho/9/alt-sq.png', 'alt-sq');
|
|
|
|
$company = Company::factory()->presseecho()->create([
|
|
'logo_path' => 'company-logos/presseecho/9/alt.png',
|
|
'logo_variants' => ['sq' => 'company-logos/presseecho/9/alt-sq.png'],
|
|
]);
|
|
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
|
|
Livewire::actingAs($admin)
|
|
->test('admin.companies.edit', ['id' => $company->id])
|
|
->set('logo', UploadedFile::fake()->image('neu.png', 400, 400))
|
|
->call('update')
|
|
->assertHasNoErrors();
|
|
|
|
$company->refresh();
|
|
|
|
expect($company->logo_path)->not->toBe('company-logos/presseecho/9/alt.png')
|
|
->and($disk->exists((string) $company->logo_path))->toBeTrue()
|
|
->and($disk->exists('company-logos/presseecho/9/alt.png'))->toBeFalse()
|
|
->and($disk->exists('company-logos/presseecho/9/alt-sq.png'))->toBeFalse();
|
|
});
|