lastFmService = m::mock(LastfmService::class); $this->mediaInformationService = new MediaInformationService($this->lastFmService); } /** * @throws Exception */ public function testGetAlbumInformation(): void { $this->expectsEvents(AlbumInformationFetched::class); /** @var Album $album */ $album = factory(Album::class)->create(); $this->lastFmService ->shouldReceive('getAlbumInformation') ->once() ->with($album->name, $album->artist->name) ->andReturn(['foo' => 'bar']); $info = $this->mediaInformationService->getAlbumInformation($album); self::assertEquals([ 'foo' => 'bar', 'cover' => $album->cover, ], $info); } /** * @throws Exception */ public function testGetArtistInformation(): void { $this->expectsEvents(ArtistInformationFetched::class); /** @var Artist $artist */ $artist = factory(Artist::class)->create(); $this->lastFmService ->shouldReceive('getArtistInformation') ->once() ->with($artist->name) ->andReturn(['foo' => 'bar']); $info = $this->mediaInformationService->getArtistInformation($artist); self::assertEquals([ 'foo' => 'bar', 'image' => $artist->image, ], $info); } }