-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
512fb16
commit 95b0ddc
Showing
6 changed files
with
293 additions
and
75 deletions.
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
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\Tests\Bootstrap; | ||
|
||
use MyParcelNL\Pdk\Api\Exception\ApiException; | ||
use MyParcelNL\Pdk\Api\Response\ClientResponse; | ||
use MyParcelNL\Pdk\App\Action\Contract\ActionInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MockApiExceptionAction implements ActionInterface | ||
{ | ||
/** | ||
* @param \Symfony\Component\HttpFoundation\Request $request | ||
* | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
* @throws \MyParcelNL\Pdk\Api\Exception\ApiException | ||
*/ | ||
public function handle(Request $request): Response | ||
{ | ||
$body = [ | ||
'message' => 'boom', | ||
'errors' => [ | ||
[ | ||
'code' => 24920, | ||
'message' => 'Something went wrong', | ||
], | ||
[ | ||
'code' => 74892, | ||
'message' => 'Something else also went wrong', | ||
], | ||
], | ||
'request_id' => '12345', | ||
]; | ||
|
||
$response = new ClientResponse(json_encode($body), Response::HTTP_BAD_REQUEST); | ||
|
||
throw new ApiException($response); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\Tests\Bootstrap; | ||
|
||
use MyParcelNL\Pdk\App\Action\Contract\ActionInterface; | ||
use RuntimeException; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MockExceptionAction implements ActionInterface | ||
{ | ||
/** | ||
* @param \Symfony\Component\HttpFoundation\Request $request | ||
* | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
*/ | ||
public function handle(Request $request): Response | ||
{ | ||
$previous = new RuntimeException('Previous exception', 1); | ||
|
||
throw new RuntimeException('Something went terribly wrong', 5, $previous); | ||
} | ||
} |
Oops, something went wrong.