ApiDocControllerSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_extends_controller() 0 4 1
A it_index_action() 0 13 1
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace spec\Kreta\SimpleApiDocBundle\Controller;
14
15
use Kreta\SimpleApiDocBundle\Extractor\ApiDocExtractor;
16
use Nelmio\ApiDocBundle\Formatter\HtmlFormatter;
17
use PhpSpec\ObjectBehavior;
18
use Symfony\Component\DependencyInjection\ContainerInterface;
19
20
/**
21
 * Spec of Api Doc controller class.
22
 *
23
 * @author Beñat Espiña <[email protected]>
24
 */
25
class ApiDocControllerSpec extends ObjectBehavior
26
{
27
    function let(ContainerInterface $container)
28
    {
29
        $this->setContainer($container);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Kreta\SimpleApiDocBundle\Controller\ApiDocController');
35
    }
36
37
    function it_extends_controller()
38
    {
39
        $this->shouldHaveType('Symfony\Bundle\FrameworkBundle\Controller\Controller');
40
    }
41
42
    function it_index_action(
43
        ContainerInterface $container,
44
        ApiDocExtractor $apiDocExtractor,
45
        HtmlFormatter $htmlFormatter
46
    ) {
47
        $container->get('kreta_simple_api_doc.extractor.api_doc_extractor')
48
            ->shouldBeCalled()->willReturn($apiDocExtractor);
49
        $apiDocExtractor->all()->shouldBeCalled()->willReturn([]);
50
        $container->get('nelmio_api_doc.formatter.html_formatter')->shouldBeCalled()->willReturn($htmlFormatter);
51
        $htmlFormatter->format([])->shouldBeCalled()->willReturn('formatted result');
52
53
        $this->indexAction()->shouldReturnAnInstanceOf('Symfony\Component\HttpFoundation\Response');
54
    }
55
}
56