diff --git a/tests/Auth/AuthTest.php b/tests/Auth/AuthTest.php index a0de7f803..f88fc1904 100644 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@ -9,6 +9,7 @@ use BookStack\Settings\SettingService; use DB; use Hash; use Illuminate\Support\Facades\Notification; +use Illuminate\Support\Str; use Tests\BrowserKitTest; class AuthTest extends BrowserKitTest @@ -221,6 +222,7 @@ class AuthTest extends BrowserKitTest public function test_user_creation() { + /** @var User $user */ $user = factory(User::class)->make(); $adminRole = Role::getRole('admin'); @@ -234,8 +236,11 @@ class AuthTest extends BrowserKitTest ->type($user->password, '#password-confirm') ->press('Save') ->seePageIs('/settings/users') - ->seeInDatabase('users', $user->toArray()) + ->seeInDatabase('users', $user->only(['name', 'email'])) ->see($user->name); + + $user->refresh(); + $this->assertStringStartsWith(Str::slug($user->name), $user->slug); } public function test_user_updating() @@ -252,6 +257,9 @@ class AuthTest extends BrowserKitTest ->seePageIs('/settings/users') ->seeInDatabase('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password]) ->notSeeInDatabase('users', ['name' => $user->name]); + + $user->refresh(); + $this->assertStringStartsWith(Str::slug($user->name), $user->slug); } public function test_user_password_update() diff --git a/tests/Entity/EntitySearchTest.php b/tests/Entity/EntitySearchTest.php index 2b5dc6d74..74e4c22a7 100644 --- a/tests/Entity/EntitySearchTest.php +++ b/tests/Entity/EntitySearchTest.php @@ -122,6 +122,7 @@ class EntitySearchTest extends TestCase $page = $this->newPage(['name' => 'My new test quaffleachits', 'html' => 'this is about an orange donkey danzorbhsing']); $this->asEditor(); $editorId = $this->getEditor()->id; + $editorSlug = $this->getEditor()->slug; // Viewed filter searches $this->get('/search?term=' . urlencode('danzorbhsing {not_viewed_by_me}'))->assertSee($page->name); @@ -133,16 +134,16 @@ class EntitySearchTest extends TestCase // User filters $this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertDontSee($page->name); $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name); - $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:'.$editorId.'}'))->assertDontSee($page->name); + $this->get('/search?term=' . urlencode('danzorbhsing {updated_by: '.$editorSlug.'}'))->assertDontSee($page->name); $page->created_by = $editorId; $page->save(); $this->get('/search?term=' . urlencode('danzorbhsing {created_by:me}'))->assertSee($page->name); - $this->get('/search?term=' . urlencode('danzorbhsing {created_by:'.$editorId.'}'))->assertSee($page->name); + $this->get('/search?term=' . urlencode('danzorbhsing {created_by: '.$editorSlug.'}'))->assertSee($page->name); $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertDontSee($page->name); $page->updated_by = $editorId; $page->save(); $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:me}'))->assertSee($page->name); - $this->get('/search?term=' . urlencode('danzorbhsing {updated_by:'.$editorId.'}'))->assertSee($page->name); + $this->get('/search?term=' . urlencode('danzorbhsing {updated_by: '.$editorSlug.'}'))->assertSee($page->name); // Content filters $this->get('/search?term=' . urlencode('{in_name:danzorbhsing}'))->assertDontSee($page->name); diff --git a/tests/User/UserProfileTest.php b/tests/User/UserProfileTest.php index 27d97381e..a5db83c48 100644 --- a/tests/User/UserProfileTest.php +++ b/tests/User/UserProfileTest.php @@ -19,7 +19,7 @@ class UserProfileTest extends BrowserKitTest public function test_profile_page_shows_name() { $this->asAdmin() - ->visit('/user/' . $this->user->id) + ->visit('/user/' . $this->user->slug) ->see($this->user->name); } @@ -28,7 +28,7 @@ class UserProfileTest extends BrowserKitTest $content = $this->createEntityChainBelongingToUser($this->user, $this->user); $this->asAdmin() - ->visit('/user/' . $this->user->id) + ->visit('/user/' . $this->user->slug) // Check the recently created page is shown ->see($content['page']->name) // Check the recently created chapter is shown @@ -41,7 +41,7 @@ class UserProfileTest extends BrowserKitTest { $newUser = $this->getNewBlankUser(); - $this->asAdmin()->visit('/user/' . $newUser->id) + $this->asAdmin()->visit('/user/' . $newUser->slug) ->see($newUser->name) ->seeInElement('#content-counts', '0 Books') ->seeInElement('#content-counts', '0 Chapters') @@ -49,7 +49,7 @@ class UserProfileTest extends BrowserKitTest $this->createEntityChainBelongingToUser($newUser, $newUser); - $this->asAdmin()->visit('/user/' . $newUser->id) + $this->asAdmin()->visit('/user/' . $newUser->slug) ->see($newUser->name) ->seeInElement('#content-counts', '1 Book') ->seeInElement('#content-counts', '1 Chapter') @@ -64,7 +64,7 @@ class UserProfileTest extends BrowserKitTest Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE); Activity::addForEntity($entities['page'], ActivityType::PAGE_CREATE); - $this->asAdmin()->visit('/user/' . $newUser->id) + $this->asAdmin()->visit('/user/' . $newUser->slug) ->seeInElement('#recent-user-activity', 'updated book') ->seeInElement('#recent-user-activity', 'created page') ->seeInElement('#recent-user-activity', $entities['page']->name); @@ -79,7 +79,7 @@ class UserProfileTest extends BrowserKitTest Activity::addForEntity($entities['page'], ActivityType::PAGE_CREATE); $this->asAdmin()->visit('/')->clickInElement('#recent-activity', $newUser->name) - ->seePageIs('/user/' . $newUser->id) + ->seePageIs('/user/' . $newUser->slug) ->see($newUser->name); }