Skip to content

Instantly share code, notes, and snippets.

@anubisthejackle
Created December 4, 2020 19:35
Show Gist options
  • Save anubisthejackle/7388cca61d86c51b759eece64eb7540f to your computer and use it in GitHub Desktop.
Save anubisthejackle/7388cca61d86c51b759eece64eb7540f to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class HttpSeriesTest extends TestCase
{
public function testHttpRequestsInSequence() {
Http::fake();
Http::get('http://google.com');
Http::get('http://example.com');
Http::get('http://yahoo.com');
$recordedUrls = Http::recorded(fn() => true);
$urlCallingOrder = [
'http://google.com',
'http://example.com',
'http://yahoo.com',
];
while($compareUrl = array_shift($urlCallingOrder)){
list($calledUrlRequest, $calledUrlResponse) = $recordedUrls->shift();
$this->assertEquals($compareUrl, $calledUrlRequest->url());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment