Completed
Push — master ( bd4c23...b341c0 )
by Filipe
10:29
created

it_runs_http_server_middleware_stack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
namespace spec\Slick\Mvc;
4
5
use PhpSpec\Exception\Example\FailureException;
6
use Psr\Http\Message\ResponseInterface;
7
use Slick\Di\ContainerInterface;
8
use Slick\Http\Server;
9
use Slick\Mvc\Application;
10
use PhpSpec\ObjectBehavior;
11
use Prophecy\Argument;
12
13
class ApplicationSpec extends ObjectBehavior
14
{
15
    function let()
16
    {
17
        $this->beConstructedWith(__DIR__.'/Services');
18
    }
19
20
    function it_is_initializable()
21
    {
22
        $this->shouldHaveType(Application::class);
23
    }
24
25
    function it_creates_dependency_container()
26
    {
27
        $this->getContainer()->shouldBeAContainerWithParent();
28
    }
29
30
    function it_runs_http_server_middleware_stack(
31
        Server $server,
32
        ResponseInterface $response
33
    ) {
34
      $server->run()->willReturn($response);
35
      $this->setHttpServer($server);
36
      $this->run()->shouldBe($response);
37
    }
38
39
    function getMatchers()
40
    {
41
        return [
42
            'beAContainerWithParent' => function($subject) {
43
                if (!$subject instanceof ContainerInterface) {
0 ignored issues
show
Bug introduced by
The class Slick\Di\ContainerInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
44
                    throw new FailureException(
45
                        "Returned value should be a ContainerInterface, but it was not!"
46
                    );
47
                }
48
49
                if (!$subject->has('isParent') || $subject->get('isParent') !== true) {
50
                    throw new FailureException(
51
                        "The returned container must have a parent that is created form ".
52
                        "services path passed when creating the application. This container ".
53
                        "was not properly created."
54
55
                    );
56
                }
57
                return true;
58
            }
59
        ];
60
    }
61
}
62