chore: more tests for image/cover upload

This commit is contained in:
Phan An 2020-04-26 21:14:23 +02:00
parent e5a67fed05
commit b8b522b422
2 changed files with 32 additions and 2 deletions

View file

@ -34,6 +34,21 @@ class AlbumCoverTest extends TestCase
$this->putAsUser('api/album/9999/cover', [
'cover' => 'data:image/jpeg;base64,Rm9v'
], factory(User::class, 'admin')->create());
], factory(User::class, 'admin')->create())
->seeStatusCode(200);
}
public function testUpdateNotAllowedForNormalUsers(): void
{
factory(Album::class)->create(['id' => 9999]);
$this->mediaMetadataService
->shouldReceive('writeAlbumCover')
->never();
$this->putAsUser('api/album/9999/cover', [
'cover' => 'data:image/jpeg;base64,Rm9v'
], factory(User::class)->create())
->seeStatusCode(403);
}
}

View file

@ -34,6 +34,21 @@ class ArtistImageTest extends TestCase
$this->putAsUser('api/artist/9999/image', [
'image' => 'data:image/jpeg;base64,Rm9v'
], factory(User::class, 'admin')->create());
], factory(User::class, 'admin')->create())
->seeStatusCode(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())
->seeStatusCode(403);
}
}