koel/tests/Feature/YouTubeTest.php

36 lines
822 B
PHP
Raw Normal View History

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;
use App\Services\YouTubeService;
2018-08-24 15:27:19 +00:00
use Mockery;
2022-07-29 06:47:10 +00:00
use Mockery\MockInterface;
2024-01-09 18:34:40 +00:00
use Tests\TestCase;
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
{
2022-07-29 06:47:10 +00:00
private MockInterface $youTubeService;
2019-07-22 07:03:23 +00:00
public function setUp(): void
{
parent::setUp();
2020-12-22 23:01:49 +00:00
$this->youTubeService = self::mock(YouTubeService::class);
}
2018-08-24 15:27:19 +00:00
public function testSearchYouTubeVideos(): void
2016-07-14 08:47:50 +00:00
{
/** @var Song $song */
2024-01-10 23:11:45 +00:00
$song = Song::factory()->create();
2016-07-14 08:47:50 +00:00
$this->youTubeService
->shouldReceive('searchVideosRelatedToSong')
->with(Mockery::on(static fn (Song $retrievedSong) => $song->is($retrievedSong)), 'foo')
->once();
2016-07-14 08:47:50 +00:00
2022-07-27 08:49:33 +00:00
$this->getAs("/api/youtube/search/song/{$song->id}?pageToken=foo")
2020-09-06 18:21:39 +00:00
->assertOk();
2016-07-14 08:47:50 +00:00
}
}