for(Artist::factory()->create(['name' => 'Bar']))->create(['title' => 'Foo']); $client = Mockery::mock(YouTubeClient::class); $client->shouldReceive('get') ->with('search?part=snippet&type=video&maxResults=10&pageToken=my-token&q=Foo+Bar') ->andReturn(json_decode(file_get_contents(__DIR__ . '/../../blobs/youtube/search.json'))); $service = new YouTubeService($client, app(Repository::class)); $response = $service->searchVideosRelatedToSong($song, 'my-token'); self::assertEquals('Slipknot - Snuff [OFFICIAL VIDEO]', $response->items[0]->snippet->title); self::assertNotNull(cache()->get('5becf539115b18b2df11c39adbc2bdfa')); } }