Completed
Push — scalar-types/theme ( 71f30c )
by Kamil
21:15
created

it_locates_application_resource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 4
nop 2
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Bundle\ThemeBundle\Locator;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\ThemeBundle\Locator\ApplicationResourceLocator;
18
use Sylius\Bundle\ThemeBundle\Locator\ResourceLocatorInterface;
19
use Sylius\Bundle\ThemeBundle\Locator\ResourceNotFoundException;
20
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
21
use Symfony\Component\Filesystem\Filesystem;
22
23
/**
24
 * @author Kamil Kokot <[email protected]>
25
 */
26
final class ApplicationResourceLocatorSpec extends ObjectBehavior
27
{
28
    function let(Filesystem $filesystem): void
29
    {
30
        $this->beConstructedWith($filesystem);
31
    }
32
33
    function it_implements_resource_locator_interface(): void
34
    {
35
        $this->shouldImplement(ResourceLocatorInterface::class);
36
    }
37
38
    function it_locates_application_resource(Filesystem $filesystem, ThemeInterface $theme): void
39
    {
40
        $theme->getPath()->willReturn('/theme/path');
41
42
        $filesystem->exists('/theme/path/resource')->willReturn(true);
43
44
        $this->locateResource('resource', $theme)->shouldReturn('/theme/path/resource');
45
    }
46
47
    function it_throws_an_exception_if_resource_can_not_be_located(Filesystem $filesystem, ThemeInterface $theme): void
48
    {
49
        $theme->getName()->willReturn('theme/name');
50
        $theme->getPath()->willReturn('/theme/path');
51
52
        $filesystem->exists('/theme/path/resource')->willReturn(false);
53
54
        $this->shouldThrow(ResourceNotFoundException::class)->during('locateResource', ['resource', $theme]);
55
    }
56
}
57