1 <?php namespace Tests\Api;
6 protected $apiTokenId = 'apitoken';
7 protected $apiTokenSecret = 'password';
10 * Set the API editor role as the current user via the API driver.
12 protected function actingAsApiEditor()
14 $this->actingAs($this->getEditor(), 'api');
19 * Format the given items into a standardised error format.
21 protected function errorResponse(string $message, int $code): array
23 return ["error" => ["code" => $code, "message" => $message]];
27 * Format the given (field_name => ["messages"]) array
28 * into a standard validation response format.
30 protected function validationResponse(array $messages): array
32 $err = $this->errorResponse("The given data was invalid.", 422);
33 $err['error']['validation'] = $messages;
37 * Get an approved API auth header.
39 protected function apiAuthHeader(): array
42 "Authorization" => "Token {$this->apiTokenId}:{$this->apiTokenSecret}"