Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Handler/FooterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private function prepareTemplateVars(): array {
return $vars;
}

private function getTemplate(): string {
public function getTemplate(): string {
$footerTemplate = $this->appConfig->getValueString(Application::APP_ID, 'footer_template', '');
if ($footerTemplate) {
return $footerTemplate;
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FooterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function isDefaultTemplate(): bool {
}

public function getTemplate(): string {
return $this->appConfig->getValueString(Application::APP_ID, 'footer_template', '');
return $this->footerHandler->getTemplate();
}

public function saveTemplate(string $template): void {
Expand Down
32 changes: 32 additions & 0 deletions tests/php/Unit/Handler/FooterHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,36 @@ public function testCustomValidationSiteNotOverwritten(): void {
$this->assertStringContainsString('https://custom.validation.site', $text);
$this->assertStringNotContainsString('https://default.site', $text);
}

public function testGetTemplateReturnsCustomTemplate(): void {
$customTemplate = '<div>Custom footer template {{ uuid }}</div>';
$this->appConfig->setValueString(Application::APP_ID, 'footer_template', $customTemplate);
$this->l10n = $this->l10nFactory->get(Application::APP_ID, 'en');

$template = $this->getClass()->getTemplate();

$this->assertSame($customTemplate, $template);
}

public function testGetTemplateReturnsDefaultWhenNotSet(): void {
$this->appConfig->deleteKey(Application::APP_ID, 'footer_template');
$this->l10n = $this->l10nFactory->get(Application::APP_ID, 'en');

$template = $this->getClass()->getTemplate();

$defaultTemplate = file_get_contents(__DIR__ . '/../../../../lib/Handler/Templates/footer.twig');
$this->assertNotEmpty($template);
$this->assertSame($defaultTemplate, $template);
}

public function testGetTemplateReturnsDefaultWhenEmpty(): void {
$this->appConfig->setValueString(Application::APP_ID, 'footer_template', '');
$this->l10n = $this->l10nFactory->get(Application::APP_ID, 'en');

$template = $this->getClass()->getTemplate();

$this->assertNotEmpty($template);
$defaultTemplate = file_get_contents(__DIR__ . '/../../../../lib/Handler/Templates/footer.twig');
$this->assertSame($defaultTemplate, $template);
}
}
15 changes: 13 additions & 2 deletions tests/php/Unit/Service/FooterServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,24 @@ public function testGetTemplate(): void {
$template = '<div>Custom template</div>';
$this->appConfig->setValueString(Application::APP_ID, 'footer_template', $template);

$this->footerHandler
->expects($this->once())
->method('getTemplate')
->willReturn($template);

$this->assertSame($template, $this->service->getTemplate());
}

public function testGetTemplateReturnsEmptyWhenNotSet(): void {
public function testGetTemplateReturnsDefaultWhenNotSet(): void {
$this->appConfig->deleteKey(Application::APP_ID, 'footer_template');

$this->assertSame('', $this->service->getTemplate());
$defaultTemplate = '<div>Default footer template</div>';
$this->footerHandler
->expects($this->once())
->method('getTemplate')
->willReturn($defaultTemplate);

$this->assertSame($defaultTemplate, $this->service->getTemplate());
}

#[DataProvider('provideRenderPreviewPdfScenarios')]
Expand Down
Loading