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

its_an_http_middleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace spec\Slick\Mvc\Http;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
use Psr\Http\Message\UriInterface;
8
use Slick\Http\Server\MiddlewareInterface;
9
use Slick\Http\Server\Request;
10
use Slick\Http\Uri;
11
use Slick\Mvc\Http\UrlRewriterMiddleware;
12
use PhpSpec\ObjectBehavior;
13
use Prophecy\Argument;
14
15
class UrlRewriterMiddlewareSpec extends ObjectBehavior
16
{
17
    function it_is_initializable()
18
    {
19
        $this->shouldHaveType(UrlRewriterMiddleware::class);
20
    }
21
22
    function its_an_http_middleware()
23
    {
24
        $this->shouldBeAnInstanceOf(MiddlewareInterface::class);
25
    }
26
27
    function it_cleans_the_url_query_parameter(
28
        ResponseInterface $response,
29
        ServerRequestInterface $request
30
    ) {
31
        $uri = new Uri('/?url=the/test&foo=bar');
32
        $request->getQueryParams()
33
            ->shouldBeCalled()
34
            ->willReturn(['url' => 'the/test', 'foo' => 'bar']);
35
        $request->getUri()
36
            ->shouldBeCalled()
37
            ->willReturn($uri);
38
        $request->withUri(Argument::that(function(UriInterface $uri) {
0 ignored issues
show
Bug introduced by
The method shouldBeCalled() does not seem to exist on object<Psr\Http\Message\ServerRequestInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
            return $uri->getPath() === '/the/test';
40
        }))
41
            ->shouldBeCalled()
42
            ->willReturn($request);
43
        $this->handle($request, $response)->shouldBe($response);
44
45
    }
46
}
47