shlink/module/Common/test/Template/Extension/TranslatorExtensionTest.php

37 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2017-10-12 11:13:20 +03:00
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Template\Extension;
use League\Plates\Engine;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Shlinkio\Shlink\Common\Template\Extension\TranslatorExtension;
use Zend\I18n\Translator\Translator;
class TranslatorExtensionTest extends TestCase
{
/** @var TranslatorExtension */
private $extension;
2019-02-16 12:53:45 +03:00
public function setUp(): void
{
$this->extension = new TranslatorExtension($this->prophesize(Translator::class)->reveal());
}
2019-02-17 22:28:34 +03:00
/** @test */
public function properFunctionsAreReturned()
{
$engine = $this->prophesize(Engine::class);
2018-12-07 11:17:26 +03:00
$registerTranslate = $engine->registerFunction('translate', Argument::type('callable'))->will(function () {
});
$registerLocale = $engine->registerFunction('locale', Argument::type('array'))->will(function () {
2018-11-18 22:04:12 +03:00
});
2018-11-18 22:04:12 +03:00
$this->extension->register($engine->reveal());
2018-12-07 11:17:26 +03:00
$registerTranslate->shouldHaveBeenCalledOnce();
$registerLocale->shouldHaveBeenCalledOnce();
}
}