コード例 #1
0
ファイル: YouTubeTest.php プロジェクト: phanan/koel
 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}");
 }
コード例 #2
0
ファイル: ScrobbleTest.php プロジェクト: phanan/koel
 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}");
 }
コード例 #3
0
ファイル: DownloadTest.php プロジェクト: Hebilicious/koel
 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);
 }
コード例 #4
0
ファイル: SongTest.php プロジェクト: Hebilicious/koel
 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));
 }
コード例 #5
0
 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));
 }