|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: polidog |
|
5
|
|
|
* Date: 2016/07/17 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Polidog\LaravelBundle\Tests; |
|
9
|
|
|
|
|
10
|
|
|
use Illuminate\Foundation\Application; |
|
11
|
|
|
use Illuminate\Contracts\Http\Kernel; |
|
12
|
|
|
|
|
13
|
|
|
use Phake; |
|
14
|
|
|
use Polidog\LaravelBundle\Bootstrap; |
|
15
|
|
|
use Polidog\LaravelBundle\LaravelKernel; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
class LaravelKernelTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @test |
|
24
|
|
|
*/ |
|
25
|
|
|
public function executeHandle() |
|
26
|
|
|
{ |
|
27
|
|
|
$kernelMock = Phake::mock(Kernel::class); |
|
28
|
|
|
$bootstrap = $this->getBootstrapMock($kernelMock); |
|
29
|
|
|
|
|
30
|
|
|
$kernel = new LaravelKernel($bootstrap); |
|
|
|
|
|
|
31
|
|
|
$request = new Request(); |
|
32
|
|
|
$kernel->handle($request); |
|
33
|
|
|
|
|
34
|
|
|
Phake::verify($kernelMock)->handle($request); |
|
35
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @test |
|
40
|
|
|
*/ |
|
41
|
|
|
public function executeTerminate() |
|
42
|
|
|
{ |
|
43
|
|
|
$kernelMock = Phake::mock(Kernel::class); |
|
44
|
|
|
$bootstrap = $this->getBootstrapMock($kernelMock); |
|
45
|
|
|
|
|
46
|
|
|
$kernel = new LaravelKernel($bootstrap); |
|
|
|
|
|
|
47
|
|
|
$request = new Request(); |
|
48
|
|
|
$response = new Response(); |
|
49
|
|
|
|
|
50
|
|
|
$kernel->terminate($request, $response); |
|
51
|
|
|
|
|
52
|
|
|
Phake::verify($kernelMock)->terminate($request, $response); |
|
53
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
private function getBootstrapMock($kernelMock) |
|
58
|
|
|
{ |
|
59
|
|
|
$app = Phake::mock(Application::class); |
|
60
|
|
|
Phake::when($app)->make($this->anything()) |
|
61
|
|
|
->thenReturn($kernelMock); |
|
62
|
|
|
|
|
63
|
|
|
$bootstrap = Phake::mock(Bootstrap::class); |
|
64
|
|
|
Phake::when($bootstrap)->load() |
|
65
|
|
|
->thenReturn($app); |
|
66
|
|
|
|
|
67
|
|
|
return $bootstrap; |
|
68
|
|
|
} |
|
69
|
|
|
} |
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: