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