mediaMetadataService = static::mockIocDependency(MediaMetadataService::class); } public function testUpdate(): void { $this->expectsEvents(LibraryChanged::class); factory(Artist::class)->create(['id' => 9999]); $this->mediaMetadataService ->shouldReceive('writeArtistImage') ->once() ->with(Mockery::on(static function (Artist $artist): bool { return $artist->id === 9999; }), 'Foo', 'jpeg'); $this->putAsUser('api/artist/9999/image', [ 'image' => 'data:image/jpeg;base64,Rm9v' ], factory(User::class)->states('admin')->create()) ->assertStatus(200); } public function testUpdateNotAllowedForNormalUsers(): void { factory(Artist::class)->create(['id' => 9999]); $this->mediaMetadataService ->shouldReceive('writeArtistImage') ->never(); $this->putAsUser('api/artist/9999/image', [ 'image' => 'data:image/jpeg;base64,Rm9v' ], factory(User::class)->create()) ->assertStatus(403); } }