Skip to content

Commit 9d6bc1a

Browse files
committed
Testing: Updated tests to account for recent page redirect changes
1 parent 30bf0ce commit 9d6bc1a

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

tests/Permissions/EntityPermissionsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function test_book_update_restriction()
184184

185185
$this->get($bookUrl . '/edit')->assertRedirect('/');
186186
$this->get('/')->assertSee('You do not have permission');
187-
$this->get($bookPage->getUrl() . '/edit')->assertRedirect('/');
187+
$this->get($bookPage->getUrl() . '/edit')->assertRedirect($bookPage->getUrl());
188188
$this->get('/')->assertSee('You do not have permission');
189189
$this->get($bookChapter->getUrl() . '/edit')->assertRedirect('/');
190190
$this->get('/')->assertSee('You do not have permission');
@@ -282,7 +282,7 @@ public function test_chapter_update_restriction()
282282

283283
$this->get($chapterUrl . '/edit')->assertRedirect('/');
284284
$this->get('/')->assertSee('You do not have permission');
285-
$this->get($chapterPage->getUrl() . '/edit')->assertRedirect('/');
285+
$this->get($chapterPage->getUrl() . '/edit')->assertRedirect($chapterPage->getUrl());
286286
$this->get('/')->assertSee('You do not have permission');
287287

288288
$this->setRestrictionsForTestRoles($chapter, ['view', 'update']);
@@ -341,7 +341,7 @@ public function test_page_update_restriction()
341341

342342
$this->setRestrictionsForTestRoles($page, ['view', 'delete']);
343343

344-
$this->get($pageUrl . '/edit')->assertRedirect('/');
344+
$this->get($pageUrl . '/edit')->assertRedirect($pageUrl);
345345
$this->get('/')->assertSee('You do not have permission');
346346

347347
$this->setRestrictionsForTestRoles($page, ['view', 'update']);
@@ -565,7 +565,7 @@ public function test_book_update_restriction_override()
565565

566566
$this->get($bookUrl . '/edit')->assertRedirect('/');
567567
$this->get('/')->assertSee('You do not have permission');
568-
$this->get($bookPage->getUrl() . '/edit')->assertRedirect('/');
568+
$this->get($bookPage->getUrl() . '/edit')->assertRedirect($bookPage->getUrl());
569569
$this->get('/')->assertSee('You do not have permission');
570570
$this->get($bookChapter->getUrl() . '/edit')->assertRedirect('/');
571571
$this->get('/')->assertSee('You do not have permission');

tests/Permissions/RolePermissionsTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
namespace Tests\Permissions;
44

5-
use BookStack\Activity\ActivityType;
65
use BookStack\Activity\Models\Comment;
76
use BookStack\Entities\Models\Book;
87
use BookStack\Entities\Models\Bookshelf;
98
use BookStack\Entities\Models\Chapter;
109
use BookStack\Entities\Models\Entity;
1110
use BookStack\Entities\Models\Page;
1211
use BookStack\Uploads\Image;
13-
use BookStack\Users\Models\Role;
1412
use BookStack\Users\Models\User;
1513
use Illuminate\Testing\TestResponse;
1614
use Tests\TestCase;
@@ -152,10 +150,14 @@ public function test_restrictions_manage_own_permission()
152150
/**
153151
* Check a standard entity access permission.
154152
*/
155-
private function checkAccessPermission(string $permission, array $accessUrls = [], array $visibles = [])
156-
{
153+
private function checkAccessPermission(
154+
string $permission,
155+
array $accessUrls = [],
156+
array $visibles = [],
157+
string $expectedRedirectUri = '/',
158+
) {
157159
foreach ($accessUrls as $url) {
158-
$this->actingAs($this->user)->get($url)->assertRedirect('/');
160+
$this->actingAs($this->user)->get($url)->assertRedirect($expectedRedirectUri);
159161
}
160162

161163
foreach ($visibles as $url => $text) {
@@ -535,11 +537,11 @@ public function test_page_edit_own_permission()
535537
$ownPage->getUrl() . '/edit',
536538
], [
537539
$ownPage->getUrl() => 'Edit',
538-
]);
540+
], $ownPage->getUrl());
539541

540542
$resp = $this->get($otherPage->getUrl());
541543
$this->withHtml($resp)->assertElementNotContains('.action-buttons', 'Edit');
542-
$this->get($otherPage->getUrl() . '/edit')->assertRedirect('/');
544+
$this->get($otherPage->getUrl() . '/edit')->assertRedirect($otherPage->getUrl());
543545
}
544546

545547
public function test_page_edit_all_permission()
@@ -550,7 +552,7 @@ public function test_page_edit_all_permission()
550552
$otherPage->getUrl('/edit'),
551553
], [
552554
$otherPage->getUrl() => 'Edit',
553-
]);
555+
], $otherPage->getUrl());
554556
}
555557

556558
public function test_page_delete_own_permission()

0 commit comments

Comments
 (0)