1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Quick run through of applying new test entity helper class

This commit is contained in:
Dan Brown
2022-09-29 22:11:16 +01:00
parent b56f7355aa
commit 900e853b15
47 changed files with 198 additions and 286 deletions

View File

@@ -2,7 +2,6 @@
namespace Tests\Api;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
@@ -95,7 +94,7 @@ class ChaptersApiTest extends TestCase
public function test_read_endpoint()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
$page = $chapter->pages()->first();
$resp = $this->getJson($this->baseEndpoint . "/{$chapter->id}");
@@ -127,7 +126,7 @@ class ChaptersApiTest extends TestCase
public function test_update_endpoint()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
$details = [
'name' => 'My updated API chapter',
'description' => 'A chapter created via the API',
@@ -152,7 +151,7 @@ class ChaptersApiTest extends TestCase
public function test_update_increments_updated_date_if_only_tags_are_sent()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
DB::table('chapters')->where('id', '=', $chapter->id)->update(['updated_at' => Carbon::now()->subWeek()]);
$details = [
@@ -167,7 +166,7 @@ class ChaptersApiTest extends TestCase
public function test_delete_endpoint()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
$resp = $this->deleteJson($this->baseEndpoint . "/{$chapter->id}");
$resp->assertStatus(204);
@@ -177,7 +176,7 @@ class ChaptersApiTest extends TestCase
public function test_export_html_endpoint()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
$resp = $this->get($this->baseEndpoint . "/{$chapter->id}/export/html");
$resp->assertStatus(200);
@@ -188,7 +187,7 @@ class ChaptersApiTest extends TestCase
public function test_export_plain_text_endpoint()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
$resp = $this->get($this->baseEndpoint . "/{$chapter->id}/export/plaintext");
$resp->assertStatus(200);
@@ -199,7 +198,7 @@ class ChaptersApiTest extends TestCase
public function test_export_pdf_endpoint()
{
$this->actingAsApiEditor();
$chapter = Chapter::visible()->first();
$chapter = $this->entities->chapter();
$resp = $this->get($this->baseEndpoint . "/{$chapter->id}/export/pdf");
$resp->assertStatus(200);