Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Tests\Unit\Services; use App\Models\Artist; use App\Models\Song; use App..
Decoded Output download
<?php
namespace Tests\Unit\Services;
use App\Models\Artist;
use App\Models\Song;
use App\Services\ApiClients\YouTubeClient;
use App\Services\YouTubeService;
use Illuminate\Cache\Repository;
use Mockery;
use Tests\TestCase;
class YouTubeServiceTest extends TestCase
{
public function testSearchVideosRelatedToSong(): void
{
/** @var Song $song */
$song = Song::factory()->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::assertSame('Slipknot - Snuff [OFFICIAL VIDEO]', $response->items[0]->snippet->title);
self::assertNotNull(cache()->get('5becf539115b18b2df11c39adbc2bdfa'));
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Tests\Unit\Services;
use App\Models\Artist;
use App\Models\Song;
use App\Services\ApiClients\YouTubeClient;
use App\Services\YouTubeService;
use Illuminate\Cache\Repository;
use Mockery;
use Tests\TestCase;
class YouTubeServiceTest extends TestCase
{
public function testSearchVideosRelatedToSong(): void
{
/** @var Song $song */
$song = Song::factory()->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::assertSame('Slipknot - Snuff [OFFICIAL VIDEO]', $response->items[0]->snippet->title);
self::assertNotNull(cache()->get('5becf539115b18b2df11c39adbc2bdfa'));
}
}
Function Calls
None |
Stats
MD5 | 355c60b8c118bb75523704326f5a92ef |
Eval Count | 0 |
Decode Time | 103 ms |