FallbackControllerTest::callFallback()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: polidog
5
 * Date: 2016/07/16
6
 */
7
8
namespace Polidog\LaravelBundle\Tests\Controller;
9
10
use Phake;
11
use Polidog\LaravelBundle\Controller\FallbackController;
12
use Polidog\LaravelBundle\Environment;
13
use Polidog\LaravelBundle\LaravelKernel;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
17
class FallbackControllerTest extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @test
21
     */
22
    public function callFallback()
23
    {
24
        $env = Phake::mock(Environment::class);
25
        $laravelKernel = Phake::mock(LaravelKernel::class);
26
27
        Phake::when($laravelKernel)->handle($this->isInstanceOf(Request::class))
28
            ->thenReturn(new \Illuminate\Http\Response());
29
30
        $controller = new FallbackController($env, $laravelKernel);
0 ignored issues
show
Documentation introduced by
$env is of type object<Phake_IMock>, but the function expects a object<Polidog\LaravelBundle\Environment>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$laravelKernel is of type object<Phake_IMock>, but the function expects a object<Polidog\LaravelBundle\LaravelKernel>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
        $controller->fallback();
32
33
        Phake::verify($env)->put();
34
        Phake::verify($laravelKernel)->handle($this->isInstanceOf(Request::class));
35
        Phake::verify($laravelKernel)->terminate(
36
            $this->isInstanceOf(Request::class),
37
            $this->isInstanceOf(Response::class)
38
        );
39
    }
40
}