]> BookStack Code Mirror - bookstack/blob - tests/Api/ApiDocsTest.php
Deps & Tests: Updated PHP deps, fixed test namespaces
[bookstack] / tests / Api / ApiDocsTest.php
1 <?php
2
3 namespace Tests\Api;
4
5 use Tests\TestCase;
6
7 class ApiDocsTest extends TestCase
8 {
9     use TestsApi;
10
11     protected string $endpoint = '/api/docs';
12
13     public function test_api_endpoint_redirects_to_docs()
14     {
15         $resp = $this->actingAsApiEditor()->get('/api');
16         $resp->assertRedirect('api/docs');
17     }
18
19     public function test_docs_page_returns_view_with_docs_content()
20     {
21         $resp = $this->actingAsApiEditor()->get($this->endpoint);
22         $resp->assertStatus(200);
23         $resp->assertSee(url('/api/docs.json'));
24         $resp->assertSee('Show a JSON view of the API docs data.');
25         $resp->assertHeader('Content-Type', 'text/html; charset=UTF-8');
26     }
27
28     public function test_docs_json_endpoint_returns_json()
29     {
30         $resp = $this->actingAsApiEditor()->get($this->endpoint . '.json');
31         $resp->assertStatus(200);
32         $resp->assertHeader('Content-Type', 'application/json');
33         $resp->assertJson([
34             'docs' => [[
35                 'name' => 'docs-display',
36                 'uri'  => 'api/docs',
37             ]],
38         ]);
39     }
40 }