X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b3d4c199aefd6066c444898eada3c8bb43dc5cb5..refs/pull/1756/head:/tests/CommandsTest.php diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 5df82ee51..4aef0ed26 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -1,8 +1,9 @@ asEditor(); - $entityRepo = $this->app[EntityRepo::class]; + $pageRepo = app(PageRepo::class); $page = Page::first(); - $entityRepo->updatePage($page, $page->book_id, ['name' => 'updated page', 'html' => '

new content

', 'summary' => 'page revision testing']); - $entityRepo->updatePageDraft($page, ['name' => 'updated page', 'html' => '

new content in draft

', 'summary' => 'page revision testing']); + $pageRepo->update($page, ['name' => 'updated page', 'html' => '

new content

', 'summary' => 'page revision testing']); + $pageRepo->updatePageDraft($page, ['name' => 'updated page', 'html' => '

new content in draft

', 'summary' => 'page revision testing']); $this->assertDatabaseHas('page_revisions', [ 'page_id' => $page->id, @@ -99,4 +100,22 @@ class CommandsTest extends TestCase $this->assertDatabaseHas('joint_permissions', ['entity_id' => $page->id]); } + + public function test_add_admin_command() + { + $exitCode = \Artisan::call('bookstack:create-admin', [ + '--email' => 'admintest@example.com', + '--name' => 'Admin Test', + '--password' => 'testing-4', + ]); + $this->assertTrue($exitCode === 0, 'Command executed successfully'); + + $this->assertDatabaseHas('users', [ + 'email' => 'admintest@example.com', + 'name' => 'Admin Test' + ]); + + $this->assertTrue(User::where('email', '=', 'admintest@example.com')->first()->hasSystemRole('admin'), 'User has admin role as expected'); + $this->assertTrue(\Auth::attempt(['email' => 'admintest@example.com', 'password' => 'testing-4']), 'Password stored as expected'); + } }