previousState = is_file($file) ? file_get_contents($file) : null; $state = json_decode($this->previousState ?? '{}', true) ?: []; $state['verleih'] = ['enabled' => true]; file_put_contents($file, json_encode($state)); parent::setUp(); Storage::fake('local'); $role = Role::query()->create(['name' => 'Künstlerteam']); $role->grants()->create(['ability' => 'verleih.manage']); $this->artist = User::factory()->withRoles([$role])->create(['first_name' => 'Kim', 'last_name' => 'Kunst']); } protected function tearDown(): void { $file = storage_path('app/plugins.json'); $this->previousState === null ? @unlink($file) : file_put_contents($file, $this->previousState); parent::tearDown(); } private function item(array $overrides = []): Item { return Item::query()->create(['title' => 'Sommerwiese', 'description' => '
Acryl auf Leinwand
', 'lent' => false, 'location' => 'Lager', ...$overrides]); } public function test_team_manages_pictures_everyone_sees_them_available_first(): void { $colleague = User::factory()->create(); $this->actingAs($colleague)->get('/verleih/neu')->assertForbidden(); $this->actingAs($colleague)->post('/verleih', ['title' => 'X', 'lent' => 0])->assertForbidden(); $this->actingAs($this->artist)->post('/verleih', [ 'title' => 'Blaue Stunde', 'description' => 'Öl
', 'lent' => 1, 'location' => 'Verwaltung', 'image' => UploadedFile::fake()->image('bild.jpg', 3000, 2000), ])->assertRedirect(); $lent = Item::query()->where('title', 'Blaue Stunde')->firstOrFail(); $this->assertTrue($lent->lent); $this->assertStringNotContainsString('