summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/TwigLoaderTest.php
blob: e68676436b77943c98592248a444a3e4667562bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

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
     */
    public function testFindTemplate()
    {
        $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);
    }
}