2018-08-26 02:54:52 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-08-26 02:54:52 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Renderer;
|
|
|
|
|
|
|
|
use Engelsystem\Renderer\TwigLoader;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use ReflectionClass as Reflection;
|
|
|
|
|
|
|
|
class TwigLoaderTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Renderer\TwigLoader::findTemplate
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testFindTemplate(): void
|
2018-08-26 02:54:52 +02:00
|
|
|
{
|
|
|
|
$loader = new TwigLoader();
|
|
|
|
|
|
|
|
$reflection = new Reflection(get_class($loader));
|
|
|
|
$property = $reflection->getProperty('cache');
|
|
|
|
$property->setAccessible(true);
|
|
|
|
|
|
|
|
$realPath = __DIR__ . '/Stub/foo.twig';
|
|
|
|
$property->setValue($loader, ['Stub/foo.twig' => $realPath]);
|
|
|
|
|
|
|
|
$return = $loader->findTemplate('Stub/foo.twig');
|
|
|
|
$this->assertEquals($realPath, $return);
|
|
|
|
|
|
|
|
$return = $loader->findTemplate('Stub/foo');
|
|
|
|
$this->assertEquals($realPath, $return);
|
|
|
|
}
|
|
|
|
}
|