Simplify song tests

This commit is contained in:
An Phan 2016-09-26 14:49:30 +08:00
parent b0f5b3d76e
commit fe3600670e
No known key found for this signature in database
GPG key ID: 05536BB4BCDC02A2
4 changed files with 15 additions and 16 deletions

View file

@ -75,7 +75,7 @@ class SongController extends Controller
'lyrics' => $song->lyrics,
'album_info' => $song->album->getInfo(),
'artist_info' => $song->artist->getInfo(),
'youtube' => YouTube::searchVideosRelatedToSong($song),
'youtube' => $song->getRelatedYouTubeVideos(),
]);
}

View file

@ -18,6 +18,6 @@ class YouTubeController extends Controller
*/
public function searchVideosRelatedToSong(Request $request, Song $song)
{
return response()->json(YouTube::searchVideosRelatedToSong($song, $request->pageToken));
return response()->json($song->getRelatedYouTubeVideos($request->pageToken));
}
}

View file

@ -8,6 +8,7 @@ use Aws\AwsClient;
use Cache;
use Illuminate\Database\Eloquent\Model;
use Lastfm;
use YouTube;
/**
* @property string path
@ -281,6 +282,18 @@ class Song extends Model
return $url;
}
/**
* Get the YouTube videos related to this song.
*
* @param string $youTubePageToken The YouTube page token, for pagination purpose.
*
* @return @return object|false
*/
public function getRelatedYouTubeVideos($youTubePageToken = '')
{
return YouTube::searchVideosRelatedToSong($this, $youTubePageToken);
}
/**
* Sometimes the tags extracted from getID3 are HTML entity encoded.
* This makes sure they are always sane.

View file

@ -304,20 +304,6 @@ class SongTest extends TestCase
]);
}
public function testGetSongInfo()
{
$song = Song::first();
$this->actingAs(factory(User::class, 'admin')->create())
->get("/api/{$song->id}/info")
->seeStatusCode(200)
->seeJson([
'lyrics' => $song->lyrics,
'artist_info' => false,
'album_info' => false,
]);
}
public function testGetObjectStoragePublicUrl()
{
$song = Song::first();