]> BookStack Code Mirror - bookstack/blob - tests/Commands/RegeneratePermissionsCommandTest.php
d5b34ba170c4e8c41aaf826061f7df6646d93445
[bookstack] / tests / Commands / RegeneratePermissionsCommandTest.php
1 <?php namespace Tests\Commands;
2
3 use BookStack\Auth\Permissions\JointPermission;
4 use BookStack\Entities\Models\Page;
5 use Illuminate\Support\Facades\DB;
6 use Tests\TestCase;
7
8 class RegeneratePermissionsCommandTest extends TestCase
9 {
10     public function test_regen_permissions_command()
11     {
12         \DB::rollBack();
13         JointPermission::query()->truncate();
14         $page = Page::first();
15
16         $this->assertDatabaseMissing('joint_permissions', ['entity_id' => $page->id]);
17
18         $exitCode = \Artisan::call('bookstack:regenerate-permissions');
19         $this->assertTrue($exitCode === 0, 'Command executed successfully');
20         DB::beginTransaction();
21
22         $this->assertDatabaseHas('joint_permissions', ['entity_id' => $page->id]);
23     }
24 }