Completed
Push — master ( 4207f0...333332 )
by Kamil
23:19 queued 01:42
created

TemplateLocatorSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 6
Bugs 1 Features 0
Metric Value
wmc 5
c 6
b 1
f 0
lcom 0
cbo 4
dl 0
loc 41
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_template_locator_interface() 0 4 1
A it_proxies_locating_template_to_resource_locator() 0 11 1
A it_does_not_catch_exceptions_throwed_while_locating_template_to_resource_locator_even() 0 11 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Sylius\Bundle\ThemeBundle\Templating\Locator;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Locator\ResourceLocatorInterface;
17
use Sylius\Bundle\ThemeBundle\Locator\ResourceNotFoundException;
18
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
19
use Sylius\Bundle\ThemeBundle\Templating\Locator\TemplateLocator;
20
use Sylius\Bundle\ThemeBundle\Templating\Locator\TemplateLocatorInterface;
21
use Symfony\Component\Templating\TemplateReferenceInterface;
22
23
/**
24
 * @mixin TemplateLocator
25
 *
26
 * @author Kamil Kokot <[email protected]>
27
 */
28
class TemplateLocatorSpec extends ObjectBehavior
29
{
30
    function let(ResourceLocatorInterface $resourceLocator)
31
    {
32
        $this->beConstructedWith($resourceLocator);
33
    }
34
35
    function it_is_initializable()
36
    {
37
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Templating\Locator\TemplateLocator');
38
    }
39
40
    function it_implements_template_locator_interface()
41
    {
42
        $this->shouldImplement(TemplateLocatorInterface::class);
43
    }
44
45
    function it_proxies_locating_template_to_resource_locator(
46
        ResourceLocatorInterface $resourceLocator,
47
        TemplateReferenceInterface $template,
48
        ThemeInterface $theme
49
    ) {
50
        $template->getPath()->willReturn('@AcmeBundle/Resources/views/index.html.twig');
51
52
        $resourceLocator->locateResource('@AcmeBundle/Resources/views/index.html.twig', $theme)->willReturn('/acme/index.html.twig');
53
54
        $this->locateTemplate($template, $theme)->shouldReturn('/acme/index.html.twig');
55
    }
56
57
    function it_does_not_catch_exceptions_throwed_while_locating_template_to_resource_locator_even(
58
        ResourceLocatorInterface $resourceLocator,
59
        TemplateReferenceInterface $template,
60
        ThemeInterface $theme
61
    ) {
62
        $template->getPath()->willReturn('@AcmeBundle/Resources/views/index.html.twig');
63
64
        $resourceLocator->locateResource('@AcmeBundle/Resources/views/index.html.twig', $theme)->willThrow(ResourceNotFoundException::class);
65
66
        $this->shouldThrow(ResourceNotFoundException::class)->during('locateTemplate', [$template, $theme]);
67
    }
68
}
69