public function testSearchVideosRelatedToSong() { $this->createSampleMediaSet(); $song = Song::first(); // We test on the facade here YouTubeFacade::shouldReceive('searchVideosRelatedToSong')->once(); $this->visit("/api/youtube/search/song/{$song->id}"); }
public function testScrobble() { $this->withoutEvents(); $this->createSampleMediaSet(); $song = Song::first(); $ts = time(); m::mock(Lastfm::class, ['enabled' => true])->shouldReceive('scrobble')->with($song->album->artist->name, $song->title, $ts, $song->album->name, 'bar'); $this->post("/api/{$song->id}/scrobble/{$ts}"); }
public function testOneSong() { $song = Song::first(); $mocked = Download::shouldReceive('from')->once()->andReturn($this->mediaPath . '/blank.mp3'); $this->get("api/download/songs?songs[]={$song->id}")->seeStatusCode(200); }
public function testGetObjectStoragePublicUrl() { $song = Song::first(); $song->path = 's3://foo/bar.mp3'; $fakeUrl = 'http://aws.com/foo/bar.mp3'; $client = m::mock(AwsClient::class, ['getCommand' => null, 'createPresignedRequest' => m::mock(Request::class, ['getUri' => $fakeUrl])]); Cache::shouldReceive('get')->once()->with("OSUrl/{$song->id}"); Cache::shouldReceive('put')->once()->with("OSUrl/{$song->id}", $fakeUrl, 60); $this->assertEquals($fakeUrl, $song->getObjectStoragePublicUrl($client)); }
public function testUpdateNowPlaying() { $this->withoutEvents(); $this->createSampleMediaSet(); $user = factory(User::class)->create(['preferences' => ['lastfm_session_key' => 'bar']]); $song = Song::first(); $lastfm = m::mock(Lastfm::class, ['enabled' => true]); $lastfm->shouldReceive('updateNowPlaying')->with($song->album->artist->name, $song->title, $song->album->name, $song->length, 'bar'); (new UpdateLastfmNowPlaying($lastfm))->handle(new SongStartedPlaying($song, $user)); }