NameDeducerSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 0
cbo 3
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 8 1
A it_should_deduce_standard_controller_names() 0 9 1
A it_should_deduce_service_controller_names() 0 10 1
A it_should_use_view_attribute_if_given() 0 8 1
1
<?php
2
3
namespace spec\Knp\RadBundle\View;
4
5
use PhpSpec\ObjectBehavior;
6
7
class NameDeducerSpec extends ObjectBehavior
8
{
9
    /**
10
     * @param Symfony\Component\DependencyInjection\ContainerInterface               $container
11
     * @param Symfony\Component\HttpFoundation\Request                               $request
12
     * @param Symfony\Bundle\FrameworkBundle\Templating\EngineInterface              $engine
13
     * @param Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser         $cnp
14
     * @param Knp\RadBundle\HttpFoundation\RequestManipulator                        $reqManip
15
     * @param Knp\RadBundle\AppBundle\BundleGuesser                                  $bundleGuesser
16
     * @param Symfony\Component\HttpKernel\Bundle\BundleInterface                    $bundle
17
     */
18
    function let($container, $request, $engine, $cnp, $reqManip, $bundleGuesser, $bundle)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        $bundleGuesser->hasBundleForClass(\Prophecy\Argument::any())->willReturn(true);
21
        $bundleGuesser->getBundleForClass(\Prophecy\Argument::any())->willReturn($bundle);
22
        $bundle->getName()->willReturn('App');
23
24
        $this->beConstructedWith($container, $engine, $cnp, $bundleGuesser, $reqManip,  'twig');
0 ignored issues
show
Coding Style introduced by
Expected 1 space instead of 2 after comma in function call.
Loading history...
25
    }
26
27
    function it_should_deduce_standard_controller_names($request, $reqManip, $engine)
0 ignored issues
show
Unused Code introduced by
The parameter $engine is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Method name "NameDeducerSpec::it_should_deduce_standard_controller_names" is not in camel caps format
Loading history...
28
    {
29
        $reqManip->hasAttribute($request, 'view')->willReturn(false);
30
        $reqManip->hasAttribute($request, '_controller')->willReturn(true);
31
        $reqManip->getAttribute($request, '_controller')->willReturn('App\Controller\CheeseController::eatAction');
32
        $request->getRequestFormat()->willReturn('html');
33
34
        $this->deduce($request)->shouldReturn('App:Cheese:eat.html.twig');
35
    }
36
37
    function it_should_deduce_service_controller_names($container, $request, $reqManip, $engine)
0 ignored issues
show
Unused Code introduced by
The parameter $engine is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Method name "NameDeducerSpec::it_should_deduce_service_controller_names" is not in camel caps format
Loading history...
38
    {
39
        $reqManip->hasAttribute($request, 'view')->willReturn(false);
40
        $reqManip->hasAttribute($request, '_controller')->willReturn(true);
41
        $reqManip->getAttribute($request, '_controller')->willReturn('app.controller.assistant:eatAction');
42
        $container->get('app.controller.assistant')->willReturn(new \Knp\RadBundle\Controller\AssistantController);
43
        $request->getRequestFormat()->willReturn('html');
44
45
        $this->deduce($request)->shouldReturn('App:Assistant:eat.html.twig');
46
    }
47
48
    function it_should_use_view_attribute_if_given($request, $reqManip, $engine)
0 ignored issues
show
Unused Code introduced by
The parameter $engine is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
Method name "NameDeducerSpec::it_should_use_view_attribute_if_given" is not in camel caps format
Loading history...
49
    {
50
        $reqManip->hasAttribute($request, 'view')->willReturn(true);
51
        $reqManip->getAttribute($request, 'view')->willReturn('App:Cheese:eat');
52
        $request->getRequestFormat()->willReturn('html');
53
54
        $this->deduce($request)->shouldReturn('App:Cheese:eat.html.twig');
55
    }
56
}
57