|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Knp\RadBundle\View; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
|
|
7
|
|
|
class PathDeducerSpec extends ObjectBehavior |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @param Symfony\Component\Templating\TemplateNameParserInterface $nameParser |
|
11
|
|
|
* @param Symfony\Component\Templating\TemplateReferenceInterface $tplRef |
|
12
|
|
|
* @param Knp\RadBundle\Filesystem\PathExpander $pathExpander |
|
13
|
|
|
*/ |
|
14
|
|
|
function let($nameParser, $pathExpander, $tplRef) |
|
|
|
|
|
|
15
|
|
|
{ |
|
16
|
|
|
$this->beConstructedWith( |
|
17
|
|
|
$nameParser, |
|
18
|
|
|
$pathExpander, |
|
19
|
|
|
array('new' => 'KnpRadBundle:Assistant/skeleton:_new.html.twig',), |
|
20
|
|
|
'KnpRadBundle:Assistant/skeleton:_viewBody.html.twig' |
|
21
|
|
|
); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function it_should_deduce_path($nameParser, $pathExpander, $tplRef) |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
$nameParser->parse('App:Cheeses:eat.html.twig')->willReturn($tplRef); |
|
27
|
|
|
$tplRef->getPath()->willReturn('@App/Resources/views/Cheeses/eat.html.twig'); |
|
28
|
|
|
|
|
29
|
|
|
$pathExpander->expand('@App/Resources/views/Cheeses/eat.html.twig')->willReturn('/expanded/path'); |
|
30
|
|
|
|
|
31
|
|
|
$this->deducePath('App:Cheeses:eat.html.twig')->shouldReturn('/expanded/path'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_should_deduce_the_skeleton_for_registered_names($nameParser, $pathExpander, $tplRef) |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
$nameParser->parse('App:Cheeses:new.html.twig')->willReturn($tplRef); |
|
37
|
|
|
$tplRef->get('name')->willReturn('new'); |
|
38
|
|
|
|
|
39
|
|
|
$this->deduceViewLogicalName('App:Cheeses:new.html.twig')->shouldReturn('KnpRadBundle:Assistant/skeleton:_new.html.twig'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function it_should_deduce_the_fallback_skeleton_name($nameParser, $pathExpander, $tplRef) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
$nameParser->parse('App:Cheeses:eat.html.twig')->willReturn($tplRef); |
|
45
|
|
|
$tplRef->get('name')->willReturn('eat'); |
|
46
|
|
|
|
|
47
|
|
|
$this->deduceViewLogicalName('App:Cheeses:eat.html.twig')->shouldReturn('KnpRadBundle:Assistant/skeleton:_viewBody.html.twig'); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.