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; |
||
4 | |||
5 | use ArrayIterator; |
||
6 | use Doctrine\ORM\EntityManager; |
||
7 | use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget; |
||
8 | use Kunstmaan\AdminBundle\Helper\FormWidgets\ListWidget; |
||
9 | use Kunstmaan\AdminBundle\Tests\unit\Helper\FormWidgets\FakeView; |
||
10 | use PHPUnit\Framework\TestCase; |
||
11 | use Symfony\Component\Form\FormBuilder; |
||
12 | use Symfony\Component\Form\FormError; |
||
13 | use Symfony\Component\HttpFoundation\Request; |
||
14 | |||
15 | /** |
||
16 | * Class FormWidgetTest |
||
17 | */ |
||
18 | class ListWidgetTest extends TestCase |
||
19 | { |
||
20 | public function testWidget() |
||
21 | { |
||
22 | $views = new ArrayIterator(); |
||
23 | $views->vars = ['errors' => [new FormError('bang')]]; |
||
0 ignored issues
–
show
|
|||
24 | $view = new FakeView(); |
||
25 | $view->offsetSet('a', $views); |
||
26 | |||
27 | $widget = $this->createMock(FormWidget::class); |
||
28 | $builder = $this->createMock(FormBuilder::class); |
||
29 | $em = $this->createMock(EntityManager::class); |
||
30 | |||
31 | $widget->expects($this->exactly(2))->method('bindRequest')->willReturn(true); |
||
32 | $widget->expects($this->exactly(2))->method('persist')->willReturn(true); |
||
33 | $widget->expects($this->exactly(2))->method('getFormErrors')->willReturn(['error' => 'argh']); |
||
34 | $widget->expects($this->exactly(2))->method('getExtraParams')->willReturn(['x' => 'y']); |
||
35 | $widget->expects($this->exactly(2))->method('buildForm')->willReturn(true); |
||
36 | |||
37 | $listWidget = new ListWidget([$widget, clone $widget]); |
||
0 ignored issues
–
show
array($widget, clone $widget) is of type array<integer,object<PHP...kObject\\MockObject>"}> , but the function expects a array<integer,object<Kun...ormWidgets\FormWidget>> .
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...
|
|||
38 | $this->assertCount(2, $listWidget->getWidgets()); |
||
0 ignored issues
–
show
$listWidget->getWidgets() is of type array<integer,object<Kun...ormWidgets\FormWidget>> , 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...
|
|||
39 | $this->assertInstanceOf(FormWidget::class, $listWidget->getWidgets()[0]); |
||
40 | $this->assertInstanceOf(FormWidget::class, $listWidget->getWidgets()[1]); |
||
41 | |||
42 | $listWidget->bindRequest(new Request()); |
||
43 | $listWidget->buildForm($builder); |
||
0 ignored issues
–
show
$builder is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...m\FormBuilderInterface> .
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 | $listWidget->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...
|
|||
45 | |||
46 | $this->assertCount(1, $listWidget->getFormErrors($view)); |
||
0 ignored issues
–
show
$listWidget->getFormErrors($view) 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...
|
|||
47 | $this->assertEquals('KunstmaanAdminBundle:FormWidgets\ListWidget:widget.html.twig', $listWidget->getTemplate()); |
||
48 | $this->assertCount(1, $listWidget->getExtraParams(new Request())); |
||
0 ignored issues
–
show
$listWidget->getExtraPar...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...
|
|||
49 | } |
||
50 | } |
||
51 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.