-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted sort tests to non browserkit testing
Added testing to cover book sort endpoint. Closes #283
- Loading branch information
1 parent
33a2999
commit 7c9937e
Showing
4 changed files
with
126 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
<?php namespace Tests; | ||
|
||
use BookStack\Book; | ||
use BookStack\Chapter; | ||
use BookStack\Repos\EntityRepo; | ||
use BookStack\Role; | ||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase; | ||
|
||
abstract class TestCase extends BaseTestCase | ||
{ | ||
use CreatesApplication; | ||
|
||
protected $admin; | ||
|
||
/** | ||
* Set the current user context to be an admin. | ||
* @return $this | ||
*/ | ||
public function asAdmin() | ||
{ | ||
return $this->actingAs($this->getAdmin()); | ||
} | ||
|
||
/** | ||
* Get the current admin user. | ||
* @return mixed | ||
*/ | ||
public function getAdmin() { | ||
if($this->admin === null) { | ||
$adminRole = Role::getSystemRole('admin'); | ||
$this->admin = $adminRole->users->first(); | ||
} | ||
return $this->admin; | ||
} | ||
|
||
/** | ||
* Create and return a new book. | ||
* @param array $input | ||
* @return Book | ||
*/ | ||
public function newBook($input = ['name' => 'test book', 'description' => 'My new test book']) { | ||
return $this->app[EntityRepo::class]->createFromInput('book', $input, false); | ||
} | ||
|
||
/** | ||
* Create and return a new test chapter | ||
* @param array $input | ||
* @param Book $book | ||
* @return Chapter | ||
*/ | ||
public function newChapter($input = ['name' => 'test chapter', 'description' => 'My new test chapter'], Book $book) { | ||
return $this->app[EntityRepo::class]->createFromInput('chapter', $input, $book); | ||
} | ||
} |