diff --git a/site/app/Formatter/TexyFormatter.php b/site/app/Formatter/TexyFormatter.php index 2c1be1e80..536b2215f 100644 --- a/site/app/Formatter/TexyFormatter.php +++ b/site/app/Formatter/TexyFormatter.php @@ -106,7 +106,7 @@ public function getTexy(): Texy $this->texy->headingModule->idPrefix = ''; $this->texy->typographyModule->locale = substr($this->translator->getDefaultLocale(), 0, 2); // en_US → en $this->texy->allowed['phrase/del'] = true; - $this->texy->addHandler('phrase', [$this->phraseHandler, 'solve']); + $this->texy->addHandler('phrase', $this->phraseHandler->solve(...)); $this->setTopHeading($this->topHeading); return $this->texy; } diff --git a/site/app/Templating/Filters.php b/site/app/Templating/Filters.php index 9aed5076c..24f192073 100644 --- a/site/app/Templating/Filters.php +++ b/site/app/Templating/Filters.php @@ -23,13 +23,13 @@ public function __construct( public function getAll(): array { return [ - 'staticUrl' => [$this, 'staticUrl'], - 'staticImageUrl' => [$this, 'staticImageUrl'], - 'format' => [$this, 'format'], - 'localeDay' => [$this->dateTimeFormatter, 'localeDay'], - 'localeMonth' => [$this->dateTimeFormatter, 'localeMonth'], - 'localeIntervalDay' => [$this->dateTimeFormatter, 'localeIntervalDay'], - 'localeIntervalMonth' => [$this->dateTimeFormatter, 'localeIntervalMonth'], + 'staticUrl' => $this->staticUrl(...), + 'staticImageUrl' => $this->staticImageUrl(...), + 'format' => $this->format(...), + 'localeDay' => $this->dateTimeFormatter->localeDay(...), + 'localeMonth' => $this->dateTimeFormatter->localeMonth(...), + 'localeIntervalDay' => $this->dateTimeFormatter->localeIntervalDay(...), + 'localeIntervalMonth' => $this->dateTimeFormatter->localeIntervalMonth(...), ]; } diff --git a/site/tests/Formatter/TexyPhraseHandlerTest.phpt b/site/tests/Formatter/TexyPhraseHandlerTest.phpt index e8e274d2b..36e208b3b 100644 --- a/site/tests/Formatter/TexyPhraseHandlerTest.phpt +++ b/site/tests/Formatter/TexyPhraseHandlerTest.phpt @@ -37,7 +37,7 @@ class TexyPhraseHandlerTest extends TestCase TexyPhraseHandler $phraseHandler, ) { $this->texy = new Texy(); - $this->texy->addHandler('phrase', [$phraseHandler, 'solve']); + $this->texy->addHandler('phrase', $phraseHandler->solve(...)); $applicationPresenter->setLinkCallback($application, $this->buildUrl(...)); $this->defaultLocale = $translator->getDefaultLocale(); } diff --git a/site/tests/Templating/TemplateFactoryTest.phpt b/site/tests/Templating/TemplateFactoryTest.phpt index e0aeefcaf..85452d7d8 100644 --- a/site/tests/Templating/TemplateFactoryTest.phpt +++ b/site/tests/Templating/TemplateFactoryTest.phpt @@ -4,6 +4,7 @@ declare(strict_types = 1); namespace MichalSpacekCz\Templating; +use DateTimeImmutable; use MichalSpacekCz\Templating\Exceptions\WrongTemplateClassException; use MichalSpacekCz\Test\TestCaseRunner; use Nette\Bridges\ApplicationLatte\DefaultTemplate; @@ -12,6 +13,7 @@ use Nette\Bridges\ApplicationLatte\Template; use Nette\InvalidArgumentException; use Spaze\NonceGenerator\Nonce; use Tester\Assert; +use Tester\FileMock; use Tester\TestCase; require __DIR__ . '/../bootstrap.php'; @@ -30,11 +32,15 @@ class TemplateFactoryTest extends TestCase public function testCreateTemplate(): void { + $file = FileMock::create('{="/foo.png"|staticUrl}, {="/bar.png"|staticImageUrl}, {="**baz**"|format}, {$start|localeDay}, {$start|localeMonth}, {$start|localeIntervalDay:$end}, {$start|localeIntervalMonth:$end}'); $template = $this->templateFactory->createTemplate(); + $template->start = new DateTimeImmutable('2023-08-23'); + $template->end = new DateTimeImmutable('2023-09-03'); Assert::type(DefaultTemplate::class, $template); $providers = $template->getLatte()->getProviders(); Assert::hasKey('uiNonce', $providers); Assert::same($this->nonce->getValue(), $providers['uiNonce']); + Assert::same('https://www.domain.example/foo.png, https://www.domain.example/i/images/bar.png, baz, 23. srpna 2023, srpen 2023, 23. srpna – 3. září 2023, srpen–září 2023', $template->renderToString($file)); }