mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-05-04 18:08:46 +03:00
Theme Modules: Added easier way to insert HTML head content
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Theme;
|
||||
|
||||
use BookStack\Facades\Theme;
|
||||
use BookStack\Util\CspService;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ThemeModuleTest extends TestCase
|
||||
@@ -220,6 +221,23 @@ class ThemeModuleTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
public function test_module_can_provide_head_content()
|
||||
{
|
||||
$this->usingModuleFolder(function (string $moduleFolderPath) {
|
||||
mkdir($moduleFolderPath . '/head', 0777, true);
|
||||
file_put_contents($moduleFolderPath . '/head/hello.html', '<meta name="beans" content="hello"><script>hellofromcustomscript</script>');
|
||||
|
||||
$this->refreshApplication();
|
||||
|
||||
$cspService = $this->app->make(CspService::class);
|
||||
$nonce = $cspService->getNonce();
|
||||
|
||||
$resp = $this->asAdmin()->get('/');
|
||||
$resp->assertSee('<meta name="beans" content="hello">', false);
|
||||
$resp->assertSee('<script nonce="' . $nonce . '">hellofromcustomscript</script>', false);
|
||||
});
|
||||
}
|
||||
|
||||
protected function usingModuleFolder(callable $callback): void
|
||||
{
|
||||
$this->usingThemeFolder(function (string $themeFolder) use ($callback) {
|
||||
|
||||
Reference in New Issue
Block a user