5 use BookStack\Repos\EntityRepo;
7 use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
9 abstract class TestCase extends BaseTestCase
11 use CreatesApplication;
16 * Set the current user context to be an admin.
19 public function asAdmin()
21 return $this->actingAs($this->getAdmin());
25 * Get the current admin user.
28 public function getAdmin() {
29 if($this->admin === null) {
30 $adminRole = Role::getSystemRole('admin');
31 $this->admin = $adminRole->users->first();
37 * Create and return a new book.
41 public function newBook($input = ['name' => 'test book', 'description' => 'My new test book']) {
42 return $this->app[EntityRepo::class]->createFromInput('book', $input, false);
46 * Create and return a new test chapter
51 public function newChapter($input = ['name' => 'test chapter', 'description' => 'My new test chapter'], Book $book) {
52 return $this->app[EntityRepo::class]->createFromInput('chapter', $input, $book);