| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Illuminate\Tests\Integration\Console\Scheduling;
- use GuzzleHttp\Client as HttpClient;
- use GuzzleHttp\Exception\ServerException;
- use GuzzleHttp\Handler\MockHandler;
- use GuzzleHttp\HandlerStack;
- use GuzzleHttp\Psr7\Response as Psr7Response;
- use Illuminate\Console\Scheduling\Event;
- use Illuminate\Console\Scheduling\EventMutex;
- use Illuminate\Contracts\Container\Container;
- use Illuminate\Contracts\Debug\ExceptionHandler;
- use Mockery as m;
- use Orchestra\Testbench\TestCase;
- class EventPingTest extends TestCase
- {
- protected function tearDown(): void
- {
- parent::tearDown();
- m::close();
- }
- public function testPingRescuesTransferExceptions()
- {
- $this->spy(ExceptionHandler::class)
- ->shouldReceive('report')
- ->once()
- ->with(m::type(ServerException::class));
- $httpMock = new HttpClient([
- 'handler' => HandlerStack::create(
- new MockHandler([new Psr7Response(500)])
- ),
- ]);
- $this->swap(HttpClient::class, $httpMock);
- $event = new Event(m::mock(EventMutex::class), 'php -i');
- $thenCalled = false;
- $event->pingBefore('https://httpstat.us/500')
- ->then(function () use (&$thenCalled) {
- $thenCalled = true;
- });
- $event->callBeforeCallbacks($this->app->make(Container::class));
- $event->callAfterCallbacks($this->app->make(Container::class));
- $this->assertTrue($thenCalled);
- }
- }
|