These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace OnurbTest\Bundle\YumlBundle\Controller; |
||
4 | |||
5 | use Onurb\Bundle\YumlBundle\Controller\YumlController; |
||
6 | use PHPUnit\Framework\TestCase; |
||
7 | use Symfony\Component\DependencyInjection\ContainerInterface; |
||
8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
9 | |||
10 | class YumlControllerTest extends TestCase |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var ContainerInterface |
||
15 | */ |
||
16 | protected $container; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $controllerName = 'Onurb\\Bundle\\YumlBundle\\Controller\\YumlController'; |
||
22 | |||
23 | /** |
||
24 | * @covers \Onurb\Bundle\YumlBundle\Controller\YumlController |
||
25 | */ |
||
26 | public function testIndexAction() |
||
27 | { |
||
28 | $yumlClient = $this->createMock('Onurb\\Bundle\\YumlBundle\\Yuml\\YumlClientInterface'); |
||
29 | |||
30 | $yumlClient->expects($this->once()) |
||
31 | ->method('makeDslText') |
||
32 | ->will($this->returnValue('[Simple.Entity|+a;b;c]')); |
||
33 | |||
34 | $yumlClient->expects($this->once()) |
||
35 | ->method('getGraphUrl') |
||
36 | ->will($this->returnValue('http://yuml.me/15a98c92.png')); |
||
37 | |||
38 | $this->container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); |
||
39 | // |
||
40 | // $this->container->expects($this->any())->method('get') |
||
41 | // ->with($this->matches('onurb_yuml.client')) |
||
42 | // ->will($this->returnValue($yumlClient)); |
||
43 | |||
44 | $this->container->expects($this->any())->method('getParameter') |
||
45 | ->will( |
||
46 | $this->returnCallback( |
||
47 | function ($arg) { |
||
48 | switch ($arg) { |
||
49 | case 'onurb_yuml.show_fields_description': |
||
50 | return false; |
||
51 | case 'onurb_yuml.colors': |
||
52 | case 'onurb_yuml.notes': |
||
53 | return array(); |
||
54 | default: |
||
55 | return false; |
||
56 | } |
||
57 | } |
||
58 | ) |
||
59 | ); |
||
60 | |||
61 | $controller = $this->createController(); |
||
62 | |||
63 | $response = $controller->indexAction($yumlClient); |
||
0 ignored issues
–
show
|
|||
64 | |||
65 | //On teste si la r�ponse est bien une redirection. |
||
66 | $this->assertTrue($response instanceof RedirectResponse); |
||
67 | } |
||
68 | |||
69 | protected function createController() |
||
70 | { |
||
71 | /** |
||
72 | * @var \Onurb\Bundle\YumlBundle\Controller\YumlController $controller |
||
73 | */ |
||
74 | $controller = new $this->controllerName; |
||
75 | $controller->setContainer($this->container); |
||
76 | |||
77 | return($controller); |
||
78 | } |
||
79 | } |
||
80 |
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: