2016-07-14 08:47:50 +00:00
|
|
|
<?php
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
namespace Tests\Feature;
|
|
|
|
|
2016-07-14 08:47:50 +00:00
|
|
|
use App\Models\Song;
|
2018-08-19 11:08:16 +00:00
|
|
|
use App\Services\YouTubeService;
|
|
|
|
use Exception;
|
2018-08-24 15:27:19 +00:00
|
|
|
use Mockery;
|
2018-08-19 11:08:16 +00:00
|
|
|
use Mockery\MockInterface;
|
2016-07-14 08:47:50 +00:00
|
|
|
|
2017-08-05 16:56:11 +00:00
|
|
|
class YouTubeTest extends TestCase
|
2016-07-14 08:47:50 +00:00
|
|
|
{
|
2018-08-24 15:27:19 +00:00
|
|
|
/** @var MockInterface */
|
2018-08-19 11:08:16 +00:00
|
|
|
private $youTubeService;
|
|
|
|
|
2019-07-22 07:03:23 +00:00
|
|
|
public function setUp(): void
|
2018-08-19 11:08:16 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->youTubeService = $this->mockIocDependency(YouTubeService::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2018-08-24 15:27:19 +00:00
|
|
|
public function testSearchYouTubeVideos(): void
|
2016-07-14 08:47:50 +00:00
|
|
|
{
|
|
|
|
$this->createSampleMediaSet();
|
|
|
|
$song = Song::first();
|
|
|
|
|
2018-08-19 11:08:16 +00:00
|
|
|
$this->youTubeService
|
|
|
|
->shouldReceive('searchVideosRelatedToSong')
|
2018-08-24 15:27:19 +00:00
|
|
|
->with(Mockery::on(static function (Song $retrievedSong) use ($song) {
|
|
|
|
return $song->id === $retrievedSong->id;
|
|
|
|
}), 'foo')
|
2018-08-19 11:08:16 +00:00
|
|
|
->once();
|
2016-07-14 08:47:50 +00:00
|
|
|
|
2018-08-24 15:27:19 +00:00
|
|
|
$this->getAsUser("/api/youtube/search/song/{$song->id}?pageToken=foo")
|
|
|
|
->assertResponseOk();
|
2016-07-14 08:47:50 +00:00
|
|
|
}
|
|
|
|
}
|