Completed
Push — master ( 521c0f...dbd031 )
by Alex
03:22
created

TwigConfigurationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testApply() 0 14 2
A getConfigurations() 0 7 1
A testPrepareFilesystem() 0 17 1
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