|
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
|
|
|
|