- protected function getNewUser($attributes = [])
- {
- $user = factory(\BookStack\User::class)->create($attributes);
- $role = \BookStack\Role::getRole('editor');
- $user->attachRole($role);;
- return $user;
- }
-
- /**
- * Quick way to create a new user without any permissions
- * @param array $attributes
- * @return mixed
- */
- protected function getNewBlankUser($attributes = [])
- {
- $user = factory(\BookStack\User::class)->create($attributes);
- return $user;
- }
-
- /**
- * Assert that a given string is seen inside an element.
- *
- * @param bool|string|null $element
- * @param integer $position
- * @param string $text
- * @param bool $negate
- * @return $this
- */
- protected function seeInNthElement($element, $position, $text, $negate = false)
- {
- $method = $negate ? 'assertNotRegExp' : 'assertRegExp';
-
- $rawPattern = preg_quote($text, '/');
-
- $escapedPattern = preg_quote(e($text), '/');
-
- $content = $this->crawler->filter($element)->eq($position)->html();
-
- $pattern = $rawPattern == $escapedPattern
- ? $rawPattern : "({$rawPattern}|{$escapedPattern})";
-
- $this->$method("/$pattern/i", $content);
-
- return $this;
- }
-
- /**
- * Assert that the current page matches a given URI.
- *
- * @param string $uri
- * @return $this
- */
- protected function seePageUrlIs($uri)
- {
- $this->assertEquals(
- $uri, $this->currentUri, "Did not land on expected page [{$uri}].\n"
- );
-
- return $this;
+ public function getAdmin() {
+ if($this->admin === null) {
+ $adminRole = Role::getSystemRole('admin');
+ $this->admin = $adminRole->users->first();
+ }
+ return $this->admin;