Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Commit 901334e

Browse files
committed
fix tests
1 parent cf68a37 commit 901334e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/ArtisanApiService.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class ArtisanApiService implements ArtisanApiServiceInterface
3636
*/
3737
protected $fractal;
3838

39-
protected $errorKey;
39+
protected $errorKey = 'error';
4040

41-
protected $errorDataKey;
41+
protected $errorDataKey = 'errors';
4242

43-
protected $messageKey;
43+
protected $messageKey = 'message';
4444

4545
/**
4646
* ArtisanApiService constructor.
@@ -49,9 +49,11 @@ class ArtisanApiService implements ArtisanApiServiceInterface
4949
*/
5050
public function __construct(ResponseFactory $response, Fractal $fractal)
5151
{
52-
$this->errorKey = config('api.error_message_key') ?? 'error';
53-
$this->errorDataKey = config('api.error_data_key') ?? 'errors';
54-
$this->messageKey = config('api.message_key') ?? 'message';
52+
if (function_exists('config')) {
53+
$this->errorKey = config('api.error_message_key');
54+
$this->errorDataKey = config('api.error_data_key');
55+
$this->messageKey = config('api.message_key');
56+
}
5557

5658
$this->response = $response;
5759
$this->fractal = $fractal;

tests/ArtisanApiServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function it_responds_with_error_and_optional_data()
189189
$this->assertJson($response->getContent());
190190
$this->assertJsonStringEqualsJsonString(json_encode([
191191
'error' => 'Error!',
192-
'lazers' => 'are cool',
192+
'errors' => ['lazers' => 'are cool'],
193193
'response_code' => ApiResponseCode::INVALID_REQUEST
194194
]), $response->getContent());
195195
$this->assertInstanceOf('Illuminate\Http\JsonResponse', $response);

0 commit comments

Comments
 (0)