1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Finished moving EntityTests out to new TestCase files

This commit is contained in:
Dan Brown
2021-09-17 21:29:16 +01:00
parent de8cceb0f7
commit 5d93dd258e
5 changed files with 167 additions and 167 deletions

View File

@ -2,12 +2,36 @@
namespace Tests\Entity;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use Tests\TestCase;
class ChapterTest extends TestCase
{
public function test_chapter_delete()
public function test_create()
{
/** @var Book $book */
$book = Book::query()->first();
$chapter = factory(Chapter::class)->make([
'name' => 'My First Chapter',
]);
$resp = $this->asEditor()->get($book->getUrl());
$resp->assertElementContains('a[href="' . $book->getUrl('/create-chapter') . '"]', 'New Chapter');
$resp = $this->get($book->getUrl('/create-chapter'));
$resp->assertElementContains('form[action="' . $book->getUrl('/create-chapter') . '"][method="POST"]', 'Save Chapter');
$resp = $this->post($book->getUrl('/create-chapter'), $chapter->only('name', 'description'));
$resp->assertRedirect($book->getUrl('/chapter/my-first-chapter'));
$resp = $this->get($book->getUrl('/chapter/my-first-chapter'));
$resp->assertSee($chapter->name);
$resp->assertSee($chapter->description);
}
public function test_delete()
{
$chapter = Chapter::query()->whereHas('pages')->first();
$this->assertNull($chapter->deleted_at);