forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMocksRequestException.php
More file actions
32 lines (26 loc) · 878 Bytes
/
MocksRequestException.php
File metadata and controls
32 lines (26 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Pterodactyl\Tests\Traits;
use Mockery;
use Mockery\Mock;
use Mockery\MockInterface;
use GuzzleHttp\Exception\RequestException;
trait MocksRequestException
{
private RequestException|Mock $exception;
private mixed $exceptionResponse;
/**
* Configure the exception mock to work with the Panel's default exception
* handler actions.
*/
protected function configureExceptionMock(string $abstract = RequestException::class, $response = null): void
{
$this->getExceptionMock($abstract)->shouldReceive('getResponse')->andReturn(value($response));
}
/**
* Return a mocked instance of the request exception.
*/
protected function getExceptionMock(string $abstract = RequestException::class): MockInterface
{
return $this->exception ?? $this->exception = Mockery::mock($abstract);
}
}