diff --git a/module/VuFind/src/VuFind/ContentBlock/TemplateBased.php b/module/VuFind/src/VuFind/ContentBlock/TemplateBased.php index 52968f109628fe06462d1655da7f864b0f446824..2c8723c8ce1359b054aa5f65d98675b66f8a5f68 100644 --- a/module/VuFind/src/VuFind/ContentBlock/TemplateBased.php +++ b/module/VuFind/src/VuFind/ContentBlock/TemplateBased.php @@ -122,7 +122,7 @@ class TemplateBased implements ContentBlockInterface protected function getContextForPhtml(string $page, string $path): array { return [ - 'templateName' => $this->templateName, + 'templateName' => $page, ]; } } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ContentBlock/TemplateBasedTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ContentBlock/TemplateBasedTest.php index 6fde869b38f3757d8ff6c29328eaa1c584b90310..dbc9ede0862d96dee99b08e6fefb6eb74e68bf23 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ContentBlock/TemplateBasedTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ContentBlock/TemplateBasedTest.php @@ -58,6 +58,24 @@ class TemplateBasedTest extends \PHPUnit\Framework\TestCase $this->assertEquals(['templateName' => 'foo'], $block->getContext()); } + /** + * Test functionality of .phtml content block w/ i18n. + * + * @return void + */ + public function testI18nPhtmlFunctionality() + { + $locator = $this->getMockBuilder(\VuFind\Content\PageLocator::class) + ->disableOriginalConstructor() + ->getMock(); + $locator->expects($this->once())->method('determineTemplateAndRenderer') + ->with($this->equalTo('templates/ContentBlock/TemplateBased/'), $this->equalTo('foo')) + ->will($this->returnValue(['renderer' => 'phtml', 'page' => 'foo_en', 'path' => '/path/to/foo_en.phtml'])); + $block = new \VuFind\ContentBlock\TemplateBased($locator); + $block->setConfig('foo'); + $this->assertEquals(['templateName' => 'foo_en'], $block->getContext()); + } + /** * Test basic functionality of Markdown content block. *