mediaMetadataService = self::mock(MediaMetadataService::class); } #[Test] public function update(): void { $album = Album::factory()->create(); $this->mediaMetadataService ->shouldReceive('writeAlbumCover') ->once() ->with(Mockery::on(static fn (Album $target) => $target->is($album)), 'data:image/jpeg;base64,Rm9v'); $this->putAs("api/album/$album->id/cover", ['cover' => 'data:image/jpeg;base64,Rm9v'], create_admin()) ->assertOk(); } #[Test] public function updateNotAllowedForNormalUsers(): void { $album = Album::factory()->create(); $this->mediaMetadataService->shouldNotReceive('writeAlbumCover'); $this->putAs('api/album/' . $album->id . '/cover', ['cover' => 'data:image/jpeg;base64,Rm9v'], create_user()) ->assertForbidden(); } }