Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/tests/Traits/MocksRequestException.php
7458 views
1
<?php
2
3
namespace Pterodactyl\Tests\Traits;
4
5
use Mockery\Mock;
6
use Mockery\MockInterface;
7
use GuzzleHttp\Exception\RequestException;
8
9
trait MocksRequestException
10
{
11
private RequestException|Mock $exception;
12
13
private mixed $exceptionResponse;
14
15
/**
16
* Configure the exception mock to work with the Panel's default exception
17
* handler actions.
18
*/
19
protected function configureExceptionMock(string $abstract = RequestException::class, $response = null): void
20
{
21
$this->getExceptionMock($abstract)->shouldReceive('getResponse')->andReturn(value($response));
22
}
23
24
/**
25
* Return a mocked instance of the request exception.
26
*/
27
protected function getExceptionMock(string $abstract = RequestException::class): MockInterface
28
{
29
return $this->exception ?? $this->exception = \Mockery::mock($abstract);
30
}
31
}
32
33