X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/7d94da10fbb0fa6de6f24878ea5984f8de6a031c..refs/pull/3113/head:/tests/ThemeTest.php diff --git a/tests/ThemeTest.php b/tests/ThemeTest.php index be3fc4ebd..364bf6900 100644 --- a/tests/ThemeTest.php +++ b/tests/ThemeTest.php @@ -1,13 +1,17 @@ -assertInstanceOf(ConfigurableEnvironmentInterface::class, $environment); $callbackCalled = true; + return $environment; }; Theme::listen(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $callback); @@ -147,7 +152,7 @@ class ThemeTest extends TestCase Theme::listen(ThemeEvents::AUTH_REGISTER, $callback); $this->setSettings(['registration-enabled' => 'true']); - $user = factory(User::class)->make(); + $user = User::factory()->make(); $this->post('/register', ['email' => $user->email, 'name' => $user->name, 'password' => 'password']); $this->assertCount(2, $args); @@ -158,8 +163,8 @@ class ThemeTest extends TestCase public function test_add_social_driver() { Theme::addSocialDriver('catnet', [ - 'client_id' => 'abc123', - 'client_secret' => 'def456' + 'client_id' => 'abc123', + 'client_secret' => 'def456', ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handleTesting'); $this->assertEquals('catnet', config('services.catnet.name')); @@ -173,9 +178,9 @@ class ThemeTest extends TestCase public function test_add_social_driver_uses_name_in_config_if_given() { Theme::addSocialDriver('catnet', [ - 'client_id' => 'abc123', + 'client_id' => 'abc123', 'client_secret' => 'def456', - 'name' => 'Super Cat Name', + 'name' => 'Super Cat Name', ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handleTesting'); $this->assertEquals('Super Cat Name', config('services.catnet.name')); @@ -183,15 +188,14 @@ class ThemeTest extends TestCase $loginResp->assertSee('Super Cat Name'); } - public function test_add_social_driver_allows_a_configure_for_redirect_callback_to_be_passed() { Theme::addSocialDriver( 'discord', [ - 'client_id' => 'abc123', + 'client_id' => 'abc123', 'client_secret' => 'def456', - 'name' => 'Super Cat Name', + 'name' => 'Super Cat Name', ], 'SocialiteProviders\Discord\DiscordExtendSocialite@handle', function ($driver) { @@ -204,11 +208,20 @@ class ThemeTest extends TestCase $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); + } protected function usingThemeFolder(callable $callback) { // Create a folder and configure a theme - $themeFolderName = 'testing_theme_' . rtrim(base64_encode(time()), "="); + $themeFolderName = 'testing_theme_' . rtrim(base64_encode(time()), '='); config()->set('view.theme', $themeFolderName); $themeFolderPath = theme_path(''); File::makeDirectory($themeFolderPath); @@ -218,5 +231,14 @@ class ThemeTest extends TestCase // Cleanup the custom theme folder we created File::deleteDirectory($themeFolderPath); } +} + +class MyCustomCommand extends Command +{ + protected $signature = 'bookstack:test-custom-command'; -} \ No newline at end of file + public function handle() + { + $this->line('Command ran!'); + } +}