imageWriter = Mockery::mock(ImageWriter::class); $this->mediaMetadataService = new MediaMetadataService($this->imageWriter, app(Logger::class)); } public function testWriteAlbumCover(): void { /** @var Album $album */ $album = factory(Album::class)->create(); $coverContent = 'dummy'; $coverPath = '/koel/public/images/album/foo.jpg'; $this->imageWriter ->shouldReceive('writeFromBinaryData') ->once() ->with('/koel/public/images/album/foo.jpg', 'dummy'); $this->mediaMetadataService->writeAlbumCover($album, $coverContent, 'jpg', $coverPath); self::assertEquals(album_cover_url('foo.jpg'), Album::find($album->id)->cover); } public function testWriteArtistImage(): void { /** @var Artist $artist */ $artist = factory(Artist::class)->create(); $imageContent = 'dummy'; $imagePath = '/koel/public/images/artist/foo.jpg'; $this->imageWriter ->shouldReceive('writeFromBinaryData') ->once() ->with('/koel/public/images/artist/foo.jpg', 'dummy'); $this->mediaMetadataService->writeArtistImage($artist, $imageContent, 'jpg', $imagePath); self::assertEquals(artist_image_url('foo.jpg'), Artist::find($artist->id)->image); } }