]> BookStack Code Mirror - bookstack/blob - tests/Api/TestsApi.php
move zip export into exportservice
[bookstack] / tests / Api / TestsApi.php
1 <?php namespace Tests\Api;
2
3 trait TestsApi
4 {
5
6     protected $apiTokenId = 'apitoken';
7     protected $apiTokenSecret = 'password';
8
9     /**
10      * Set the API editor role as the current user via the API driver.
11      */
12     protected function actingAsApiEditor()
13     {
14         $this->actingAs($this->getEditor(), 'api');
15         return $this;
16     }
17
18     /**
19      * Format the given items into a standardised error format.
20      */
21     protected function errorResponse(string $message, int $code): array
22     {
23         return ["error" => ["code" => $code, "message" => $message]];
24     }
25
26     /**
27      * Get an approved API auth header.
28      */
29     protected function apiAuthHeader(): array
30     {
31         return [
32             "Authorization" => "Token {$this->apiTokenId}:{$this->apiTokenSecret}"
33         ];
34     }
35
36 }