-
- public function test_export_html_endpoint()
- {
- $this->actingAsApiEditor();
- $page = Page::visible()->first();
-
- $resp = $this->get($this->baseEndpoint . "/{$page->id}/export/html");
- $resp->assertStatus(200);
- $resp->assertSee($page->name);
- $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.html"');
- }
-
- public function test_export_plain_text_endpoint()
- {
- $this->actingAsApiEditor();
- $page = Page::visible()->first();
-
- $resp = $this->get($this->baseEndpoint . "/{$page->id}/export/plaintext");
- $resp->assertStatus(200);
- $resp->assertSee($page->name);
- $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.txt"');
- }
-
- public function test_export_pdf_endpoint()
- {
- $this->actingAsApiEditor();
- $page = Page::visible()->first();
-
- $resp = $this->get($this->baseEndpoint . "/{$page->id}/export/pdf");
- $resp->assertStatus(200);
- $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.pdf"');
- }
-
- public function test_export_markdown_endpoint()
- {
- $this->actingAsApiEditor();
- $page = Page::visible()->first();
-
- $resp = $this->get($this->baseEndpoint . "/{$page->id}/export/markdown");
- $resp->assertStatus(200);
- $resp->assertSee('# ' . $page->name);
- $resp->assertHeader('Content-Disposition', 'attachment; filename="' . $page->slug . '.md"');
- }
-
- public function test_cant_export_when_not_have_permission()
- {
- $types = ['html', 'plaintext', 'pdf', 'markdown'];
- $this->actingAsApiEditor();
- $this->removePermissionFromUser($this->getEditor(), 'content-export');
-
- $page = Page::visible()->first();
- foreach ($types as $type) {
- $resp = $this->get($this->baseEndpoint . "/{$page->id}/export/{$type}");
- $this->assertPermissionError($resp);
- }
- }