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 Kunstmaan\AdminBundle\Tests\Helper\FormWidgets\Tabs; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\Tab; |
||
7 | use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\TabPane; |
||
8 | use PHPUnit\Framework\TestCase; |
||
9 | use Symfony\Component\Form\Form; |
||
10 | use Symfony\Component\Form\FormBuilder; |
||
11 | use Symfony\Component\Form\FormFactory; |
||
12 | use Symfony\Component\Form\FormView; |
||
13 | use Symfony\Component\HttpFoundation\Request; |
||
14 | |||
15 | /** |
||
16 | * Class TabPaneTest |
||
17 | */ |
||
18 | class TabPaneTest extends TestCase |
||
19 | { |
||
20 | /** |
||
21 | * @throws \ReflectionException |
||
22 | */ |
||
23 | public function testTabPane() |
||
24 | { |
||
25 | $request = $this->createMock(Request::class); |
||
26 | $request->request = $this->createMock(Request::class); |
||
0 ignored issues
–
show
|
|||
27 | $factory = $this->createMock(FormFactory::class); |
||
28 | $builder = $this->createMock(FormBuilder::class); |
||
29 | $form = $this->createMock(Form::class); |
||
30 | $view = $this->createMock(FormView::class); |
||
31 | $tab = $this->createMock(Tab::class); |
||
32 | $tab2 = clone $tab; |
||
33 | |||
34 | $request->expects($this->exactly(2))->method('get')->willReturn($tab); |
||
35 | $tab->expects($this->any())->method('getExtraParams')->willReturn([1, 2, 3, 4, 5]); |
||
36 | $tab->expects($this->any())->method('getTitle')->willReturn('Pass!'); |
||
37 | $form->expects($this->any())->method('createView')->willReturn($view); |
||
38 | $form->expects($this->any())->method('isValid')->willReturn(true); |
||
39 | $builder->expects($this->once())->method('getForm')->willReturn($form); |
||
40 | $factory->expects($this->once())->method('createBuilder')->willReturn($builder); |
||
41 | $em = $this->createMock(EntityManager::class); |
||
42 | |||
43 | $tabPane = new TabPane('Title', $request, $factory); |
||
0 ignored issues
–
show
$request is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component\HttpFoundation\Request> .
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...
$factory is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...m\FormFactoryInterface> .
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...
|
|||
44 | |||
45 | $tabPane->addTab($tab); |
||
0 ignored issues
–
show
$tab is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\AdminBu...gets\Tabs\TabInterface> .
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...
|
|||
46 | $tabPane->addTab($tab2, 0); |
||
0 ignored issues
–
show
$tab2 is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\AdminBu...gets\Tabs\TabInterface> .
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...
|
|||
47 | $tabPane->buildForm(); |
||
48 | $tabPane->bindRequest(new Request()); |
||
49 | $tabPane->persist($em); |
||
0 ignored issues
–
show
$em is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Doctrine\ORM\EntityManager> .
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...
|
|||
50 | $tabPane->removeTab($tab2); |
||
0 ignored issues
–
show
$tab2 is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\AdminBu...gets\Tabs\TabInterface> .
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...
|
|||
51 | $this->assertCount(5, $tabPane->getExtraParams(new Request())); |
||
0 ignored issues
–
show
$tabPane->getExtraParams...tpFoundation\Request()) is of type array , but the function expects a object<Countable>|object...nit\Framework\iterable> .
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...
|
|||
52 | $this->assertInstanceOf(Form::class, $tabPane->getForm()); |
||
53 | $this->assertInstanceOf(FormView::class, $tabPane->getFormView()); |
||
54 | $this->assertTrue($tabPane->isValid()); |
||
55 | $this->assertInstanceOf(Tab::class, $tabPane->getActiveTab()); |
||
56 | $this->assertNull($tabPane->getTabByPosition(5)); |
||
57 | $this->assertNotNull($tabPane->getTabByPosition(0)); |
||
58 | $this->assertNull($tabPane->getTabByTitle('Fail!')); |
||
59 | $this->assertNotNull($tabPane->getTabByTitle('Pass!')); |
||
60 | $tabPane->removeTabByTitle('Pass!'); |
||
61 | $tabPane->removeTabByTitle('not here'); |
||
62 | $this->assertEmpty($tabPane->getTabs()); |
||
63 | $tabPane->addTab($tab); |
||
0 ignored issues
–
show
$tab is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\AdminBu...gets\Tabs\TabInterface> .
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...
|
|||
64 | $tabPane->addTab($tab2, 0); |
||
0 ignored issues
–
show
$tab2 is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\AdminBu...gets\Tabs\TabInterface> .
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...
|
|||
65 | $tabPane->removeTabByPosition(0); |
||
66 | $this->assertCount(1, $tabPane->getTabs()); |
||
0 ignored issues
–
show
$tabPane->getTabs() is of type array<integer,object<Kun...ets\Tabs\TabInterface>> , but the function expects a object<Countable>|object...nit\Framework\iterable> .
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...
|
|||
67 | |||
68 | $request->request->expects($this->exactly(2))->method('get')->willReturn($tab); |
||
0 ignored issues
–
show
Accessing
request on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
69 | new TabPane('Title', $request, $factory); |
||
0 ignored issues
–
show
$request is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component\HttpFoundation\Request> .
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...
$factory is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...m\FormFactoryInterface> .
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...
|
|||
70 | } |
||
71 | } |
||
72 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: