Skip to content

Commit

Permalink
chore: more tests for image/cover upload
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Apr 26, 2020
1 parent e5a67fe commit b8b522b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tests/Feature/AlbumCoverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ public function testUpdate(): void

$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);
}
}
17 changes: 16 additions & 1 deletion tests/Feature/ArtistImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ public function testUpdate(): void

$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);
}
}

0 comments on commit b8b522b

Please sign in to comment.