-<?php namespace Tests\Api;
+<?php
+
+namespace Tests\Api;
trait TestsApi
{
-
protected $apiTokenId = 'apitoken';
protected $apiTokenSecret = 'password';
protected function actingAsApiEditor()
{
$this->actingAs($this->getEditor(), 'api');
+
return $this;
}
*/
protected function errorResponse(string $message, int $code): array
{
- return ["error" => ["code" => $code, "message" => $message]];
+ return ['error' => ['code' => $code, 'message' => $message]];
}
/**
*/
protected function validationResponse(array $messages): array
{
- $err = $this->errorResponse("The given data was invalid.", 422);
+ $err = $this->errorResponse('The given data was invalid.', 422);
$err['error']['validation'] = $messages;
+
return $err;
}
+
/**
* Get an approved API auth header.
*/
protected function apiAuthHeader(): array
{
return [
- "Authorization" => "Token {$this->apiTokenId}:{$this->apiTokenSecret}"
+ 'Authorization' => "Token {$this->apiTokenId}:{$this->apiTokenSecret}",
];
}
-
-}
\ No newline at end of file
+}