2017-10-12 10:40:42 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-10-12 10:40:42 +03:00
|
|
|
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
|
|
|
|
{
|
2018-11-20 21:30:27 +03:00
|
|
|
/** @var TranslatorExtension */
|
2018-11-20 21:37:22 +03:00
|
|
|
private $extension;
|
2017-10-12 10:40:42 +03:00
|
|
|
|
2019-02-16 12:53:45 +03:00
|
|
|
public function setUp(): void
|
2017-10-12 10:40:42 +03:00
|
|
|
{
|
|
|
|
$this->extension = new TranslatorExtension($this->prophesize(Translator::class)->reveal());
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:28:34 +03:00
|
|
|
/** @test */
|
2017-10-12 10:40:42 +03:00
|
|
|
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
|
|
|
});
|
2017-10-12 10:40:42 +03:00
|
|
|
|
2018-11-18 22:04:12 +03:00
|
|
|
$this->extension->register($engine->reveal());
|
2017-10-12 10:40:42 +03:00
|
|
|
|
2018-12-07 11:17:26 +03:00
|
|
|
$registerTranslate->shouldHaveBeenCalledOnce();
|
|
|
|
$registerLocale->shouldHaveBeenCalledOnce();
|
2017-10-12 10:40:42 +03:00
|
|
|
}
|
|
|
|
}
|