Completed
Push — develop ( a9d829...037456 )
by Jens
04:55 queued 43s
created

HelperPassTest::testTagging()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 24
rs 8.9713
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
7
namespace JaySDe\HandlebarsBundle\Tests\DependencyInjection\Compiler;
8
9
10
use JaySDe\HandlebarsBundle\DependencyInjection\Compiler\HelperPass;
11
use Prophecy\Argument;
12
use Symfony\Component\DependencyInjection\Reference;
13
14
class HelperPassTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testTagging()
17
    {
18
        $definitionObserver = $this->prophesize('\Symfony\Component\DependencyInjection\Definition');
19
        $definitionObserver->addMethodCall(
20
            "addHelper",
21
            Argument::allOf(
22
                Argument::containing('test'),
23
                Argument::containing(new Reference('handlebars.helper.test'))
24
            )
25
        )->shouldBeCalled();
26
        $containerObserver = $this->prophesize('\Symfony\Component\DependencyInjection\ContainerBuilder');
27
        $containerObserver->has('handlebars.helper')->willReturn(true)->shouldBeCalled();
28
        $containerObserver->findDefinition('handlebars.helper')->willReturn($definitionObserver->reveal())->shouldBeCalled();
29
30
        $taggedServices = [
31
            'handlebars.helper.test' => [
32
                ['id' => 'test']
33
            ]
34
        ];
35
        $containerObserver->findTaggedServiceIds('handlebars.helper')->willReturn($taggedServices)->shouldBeCalled();
36
37
        $helperPass = new HelperPass();
38
        $helperPass->process($containerObserver->reveal());
39
    }
40
41
    public function testDisabled()
42
    {
43
        $containerObserver = $this->prophesize('\Symfony\Component\DependencyInjection\ContainerBuilder');
44
        $containerObserver->has('handlebars.helper')->willReturn(false)->shouldBeCalled();
45
46
        $helperPass = new HelperPass();
47
        $helperPass->process($containerObserver->reveal());
48
    }
49
}
50