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