mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-05-04 18:08:46 +03:00
Theme System: Fixed theme view before/after issues
- Updated the system to work with modules. - Updated module docs to consider namespacing. - Fixed view loading and registration event ordering. - Fixed checking if views are registered.
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Tests\Theme;
|
||||
use BookStack\Facades\Theme;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ThemeModuleTests extends TestCase
|
||||
class ThemeModuleTest extends TestCase
|
||||
{
|
||||
public function test_modules_loaded_on_theme_load()
|
||||
{
|
||||
@@ -207,6 +207,19 @@ class ThemeModuleTests extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
public function test_module_can_use_theme_view_render_functions()
|
||||
{
|
||||
$this->usingModuleFolder(function (string $moduleFolderPath) {
|
||||
file_put_contents($moduleFolderPath . '/functions.php', "<?php\n\BookStack\Facades\Theme::listen(\BookStack\Theming\ThemeEvents::THEME_REGISTER_VIEWS, fn(\$views) => \$views->renderBefore('layouts.parts.header', 'cat', 100));");
|
||||
mkdir($moduleFolderPath . '/views', 0777, true);
|
||||
file_put_contents($moduleFolderPath . '/views/cat.blade.php', 'mysupercatispouncy');
|
||||
|
||||
$this->refreshApplication();
|
||||
|
||||
$this->asAdmin()->get('/')->assertSee('mysupercatispouncy');
|
||||
});
|
||||
}
|
||||
|
||||
protected function usingModuleFolder(callable $callback): void
|
||||
{
|
||||
$this->usingThemeFolder(function (string $themeFolder) use ($callback) {
|
||||
Reference in New Issue
Block a user