-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Minions\Tests\Feature\Exceptions; | ||
|
||
use Illuminate\Support\Facades\Log; | ||
use Minions\Client\Response; | ||
use Minions\Exceptions\RequestException; | ||
use Minions\Tests\TestCase; | ||
use Mockery as m; | ||
|
||
class RequestExceptionTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_report_exception_to_laravel() | ||
{ | ||
$response = m::mock(Response::class); | ||
|
||
$response->shouldReceive('getRpcErrorData')->once()->andReturn([ | ||
'username' => 'The username field is required.', | ||
]); | ||
|
||
$exception = new RequestException('The given data was invalid.', -32602, $response, 'users.auth'); | ||
|
||
Log::shouldReceive('error')->once()->andReturnUsing(function ($message, $context) { | ||
$this->assertSame('The given data was invalid.', $message); | ||
|
||
$this->assertSame('users.auth', $context['method']); | ||
$this->assertSame(['username' => 'The username field is required.'], $context['error']); | ||
$this->assertInstanceOf(RequestException::class, $context['exception']); | ||
}); | ||
|
||
$exception->report(); | ||
} | ||
} |