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:
@ -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);
|
||||
|
Reference in New Issue
Block a user