mirror of
https://github.com/koel/koel
synced 2025-02-16 13:28:32 +00:00
Simplify song tests
This commit is contained in:
parent
b0f5b3d76e
commit
fe3600670e
4 changed files with 15 additions and 16 deletions
|
@ -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(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue