+ public function test_add_social_driver_allows_a_configure_for_redirect_callback_to_be_passed()
+ {
+ Theme::addSocialDriver(
+ 'discord',
+ [
+ 'client_id' => 'abc123',
+ 'client_secret' => 'def456',
+ 'name' => 'Super Cat Name',
+ ],
+ 'SocialiteProviders\Discord\DiscordExtendSocialite@handle',
+ function ($driver) {
+ $driver->with(['donkey' => 'donut']);
+ }
+ );
+
+ $loginResp = $this->get('/login/service/discord');
+ $redirect = $loginResp->headers->get('location');
+ $this->assertStringContainsString('donkey=donut', $redirect);
+ }
+
+ public function test_register_command_allows_provided_command_to_be_usable_via_artisan()
+ {
+ Theme::registerCommand(new MyCustomCommand());
+
+ Artisan::call('bookstack:test-custom-command', []);
+ $output = Artisan::output();
+
+ $this->assertStringContainsString('Command ran!', $output);
+ }
+
+ public function test_base_body_start_and_end_template_files_can_be_used()
+ {
+ $bodyStartStr = 'barry-fought-against-the-panther';
+ $bodyEndStr = 'barry-lost-his-fight-with-grace';
+
+ $this->usingThemeFolder(function (string $folder) use ($bodyStartStr, $bodyEndStr) {
+ $viewDir = theme_path('layouts/parts');
+ mkdir($viewDir, 0777, true);
+ file_put_contents($viewDir . '/base-body-start.blade.php', $bodyStartStr);
+ file_put_contents($viewDir . '/base-body-end.blade.php', $bodyEndStr);
+
+ $resp = $this->asEditor()->get('/');
+ $resp->assertSee($bodyStartStr);
+ $resp->assertSee($bodyEndStr);
+ });
+ }
+
+ public function test_export_body_start_and_end_template_files_can_be_used()
+ {
+ $bodyStartStr = 'garry-fought-against-the-panther';
+ $bodyEndStr = 'garry-lost-his-fight-with-grace';
+ $page = $this->entities->page();
+
+ $this->usingThemeFolder(function (string $folder) use ($bodyStartStr, $bodyEndStr, $page) {
+ $viewDir = theme_path('layouts/parts');
+ mkdir($viewDir, 0777, true);
+ file_put_contents($viewDir . '/export-body-start.blade.php', $bodyStartStr);
+ file_put_contents($viewDir . '/export-body-end.blade.php', $bodyEndStr);
+
+ $resp = $this->asEditor()->get($page->getUrl('/export/html'));
+ $resp->assertSee($bodyStartStr);
+ $resp->assertSee($bodyEndStr);
+ });
+ }
+
+ public function test_login_and_register_message_template_files_can_be_used()
+ {
+ $loginMessage = 'Welcome to this instance, login below you scallywag';
+ $registerMessage = 'You want to register? Enter the deets below you numpty';
+
+ $this->usingThemeFolder(function (string $folder) use ($loginMessage, $registerMessage) {
+ $viewDir = theme_path('auth/parts');
+ mkdir($viewDir, 0777, true);
+ file_put_contents($viewDir . '/login-message.blade.php', $loginMessage);
+ file_put_contents($viewDir . '/register-message.blade.php', $registerMessage);
+ $this->setSettings(['registration-enabled' => 'true']);
+
+ $this->get('/login')->assertSee($loginMessage);
+ $this->get('/register')->assertSee($registerMessage);
+ });
+ }
+