1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Asmaster\EquipTwig\Tests\Configuration; |
4
|
|
|
|
5
|
|
|
use Auryn\Injector; |
6
|
|
|
use Equip\Env; |
7
|
|
|
use Equip\Configuration\AurynConfiguration; |
8
|
|
|
use Equip\Responder\FormattedResponder; |
9
|
|
|
use Asmaster\EquipTwig\TwigFormatter; |
10
|
|
|
use Asmaster\EquipTwig\Configuration\TwigConfiguration; |
11
|
|
|
|
12
|
|
|
class TwigConfigurationTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
public function testApply() |
15
|
|
|
{ |
16
|
|
|
$injector = new Injector; |
17
|
|
|
|
18
|
|
|
foreach ($this->getConfigurations() as $config) { |
19
|
|
|
$instance = $injector->make($config); |
20
|
|
|
$instance->apply($injector); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
$responder = $injector->make(FormattedResponder::class); |
24
|
|
|
|
25
|
|
|
$this->assertArrayHasKey(TwigFormatter::class, $responder); |
26
|
|
|
$this->assertSame(1.0, $responder[TwigFormatter::class]); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function getConfigurations() |
30
|
|
|
{ |
31
|
|
|
return [ |
32
|
|
|
AurynConfiguration::class, |
33
|
|
|
TwigConfiguration::class |
34
|
|
|
]; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testPrepareFilesystem() |
38
|
|
|
{ |
39
|
|
|
$templatesDir = __DIR__.'/../_templates'; |
40
|
|
|
|
41
|
|
|
$injector = new Injector; |
42
|
|
|
$injector->prepare(Env::class, function (Env $env) use ($templatesDir) { |
43
|
|
|
return $env->withValue('TWIG_TEMPLATES', $templatesDir); |
44
|
|
|
}); |
45
|
|
|
|
46
|
|
|
$config = $injector->make(TwigConfiguration::class); |
47
|
|
|
$config->apply($injector); |
48
|
|
|
|
49
|
|
|
$loader = $injector->make(\Twig_Loader_Filesystem::class); |
50
|
|
|
|
51
|
|
|
$this->assertNotEmpty($loader->getPaths()); |
52
|
|
|
$this->assertSame($templatesDir, $loader->getPaths()[0]); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|