X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/fe54c7f27ad2c2111020b2f28c58d889794ea1c5..refs/pull/3556/head:/tests/ThemeTest.php diff --git a/tests/ThemeTest.php b/tests/ThemeTest.php index fe8162559..85b8b9d36 100644 --- a/tests/ThemeTest.php +++ b/tests/ThemeTest.php @@ -170,6 +170,7 @@ class ThemeTest extends TestCase $args = []; $callback = function (...$eventArgs) use (&$args) { $args = $eventArgs; + return ['test' => 'hello!']; }; Theme::listen(ThemeEvents::WEBHOOK_CALL_BEFORE, $callback); @@ -185,7 +186,7 @@ class ThemeTest extends TestCase dispatch((new DispatchWebhookJob($webhook, $event, $detail))); - $this->assertCount(3, $args); + $this->assertCount(5, $args); $this->assertEquals($event, $args[0]); $this->assertEquals($webhook->id, $args[1]->id); $this->assertEquals($detail->id, $args[2]->id); @@ -253,6 +254,23 @@ class ThemeTest extends TestCase $this->assertStringContainsString('Command ran!', $output); } + public function test_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); + }); + } + protected function usingThemeFolder(callable $callback) { // Create a folder and configure a theme @@ -261,7 +279,10 @@ class ThemeTest extends TestCase $themeFolderPath = theme_path(''); File::makeDirectory($themeFolderPath); - call_user_func($callback, $themeFolderName); + // Run provided callback with theme env option set + $this->runWithEnv('APP_THEME', $themeFolderName, function () use ($callback, $themeFolderName) { + call_user_func($callback, $themeFolderName); + }); // Cleanup the custom theme folder we created File::deleteDirectory($themeFolderPath);