2021-06-26 17:23:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Api;
|
2020-01-18 11:04:13 +01:00
|
|
|
|
2020-04-04 02:16:05 +02:00
|
|
|
use Tests\TestCase;
|
2020-01-18 11:04:13 +01:00
|
|
|
|
|
|
|
class ApiDocsTest extends TestCase
|
|
|
|
{
|
|
|
|
use TestsApi;
|
|
|
|
|
2023-06-21 00:44:39 +02:00
|
|
|
protected string $endpoint = '/api/docs';
|
2020-01-18 11:04:13 +01:00
|
|
|
|
2021-11-14 16:20:04 +01:00
|
|
|
public function test_api_endpoint_redirects_to_docs()
|
|
|
|
{
|
|
|
|
$resp = $this->actingAsApiEditor()->get('/api');
|
|
|
|
$resp->assertRedirect('api/docs');
|
|
|
|
}
|
|
|
|
|
2020-01-18 11:04:13 +01:00
|
|
|
public function test_docs_page_returns_view_with_docs_content()
|
|
|
|
{
|
|
|
|
$resp = $this->actingAsApiEditor()->get($this->endpoint);
|
|
|
|
$resp->assertStatus(200);
|
|
|
|
$resp->assertSee(url('/api/docs.json'));
|
|
|
|
$resp->assertSee('Show a JSON view of the API docs data.');
|
|
|
|
$resp->assertHeader('Content-Type', 'text/html; charset=UTF-8');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_docs_json_endpoint_returns_json()
|
|
|
|
{
|
|
|
|
$resp = $this->actingAsApiEditor()->get($this->endpoint . '.json');
|
|
|
|
$resp->assertStatus(200);
|
|
|
|
$resp->assertHeader('Content-Type', 'application/json');
|
|
|
|
$resp->assertJson([
|
2021-06-26 17:23:15 +02:00
|
|
|
'docs' => [[
|
2020-01-18 11:04:13 +01:00
|
|
|
'name' => 'docs-display',
|
2021-06-26 17:23:15 +02:00
|
|
|
'uri' => 'api/docs',
|
|
|
|
]],
|
2020-01-18 11:04:13 +01:00
|
|
|
]);
|
|
|
|
}
|
2021-06-26 17:23:15 +02:00
|
|
|
}
|