1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 09:02:28 +01:00
Pterodactyl-Panel/tests/Traits/MocksRequestException.php
Matthew Penner 3ea6d45cda
php-cs-fixer
2022-11-29 10:53:59 -07:00

32 lines
866 B
PHP

<?php
namespace Pterodactyl\Tests\Traits;
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);
}
}