These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Sonata Project package. |
||
7 | * |
||
8 | * (c) Thomas Rabaix <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Sonata\MediaBundle\Tests\Form\Type; |
||
15 | |||
16 | use Sonata\MediaBundle\Provider\MediaProviderInterface; |
||
17 | use Sonata\MediaBundle\Provider\Pool; |
||
18 | use Symfony\Component\Form\FormBuilder; |
||
19 | use Symfony\Component\Form\FormTypeInterface; |
||
20 | use Symfony\Component\Form\Test\TypeTestCase; |
||
21 | |||
22 | /** |
||
23 | * @author Virgile Vivier <[email protected]> |
||
24 | */ |
||
25 | abstract class AbstractTypeTest extends TypeTestCase |
||
26 | { |
||
27 | /** |
||
28 | * @var FormBuilder |
||
29 | */ |
||
30 | protected $formBuilder; |
||
31 | |||
32 | /** |
||
33 | * @var FormTypeInterface |
||
34 | */ |
||
35 | protected $formType; |
||
36 | |||
37 | /** |
||
38 | * @var Pool |
||
39 | */ |
||
40 | protected $mediaPool; |
||
41 | |||
42 | protected function setUp(): void |
||
43 | { |
||
44 | $provider = $this->getMockBuilder(MediaProviderInterface::class) |
||
45 | ->disableOriginalConstructor() |
||
46 | ->getMock(); |
||
47 | |||
48 | $this->mediaPool = $this->createMock(Pool::class); |
||
0 ignored issues
–
show
|
|||
49 | $this->mediaPool->expects($this->any())->method('getProvider')->willReturn($provider); |
||
50 | |||
51 | $this->formBuilder = $this->createMock(FormBuilder::class); |
||
0 ignored issues
–
show
It seems like
$this->createMock(\Symfo...orm\FormBuilder::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<Symfony\Component\Form\FormBuilder> of property $formBuilder .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
Loading history...
|
|||
52 | $this->formBuilder |
||
53 | ->expects($this->any()) |
||
54 | ->method('add') |
||
55 | ->willReturnCallback(function ($name, $type = null): void { |
||
56 | if (null !== $type) { |
||
57 | $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); |
||
58 | } |
||
59 | }); |
||
60 | |||
61 | $this->formType = $this->getTestedInstance(); |
||
62 | } |
||
63 | |||
64 | public function testBuildForm(): void |
||
65 | { |
||
66 | $this->formType->buildForm($this->formBuilder, [ |
||
67 | 'provider_name' => 'sonata.media.provider.image', |
||
68 | 'provider' => null, |
||
69 | 'context' => null, |
||
70 | 'empty_on_new' => true, |
||
71 | 'new_on_update' => true, |
||
72 | ]); |
||
73 | } |
||
74 | |||
75 | public function testGetParent(): void |
||
76 | { |
||
77 | $parentRef = $this->formType->getParent(); |
||
78 | $this->assertTrue(class_exists($parentRef), sprintf('Unable to ensure %s is a FQCN', $parentRef)); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Get the tested form type instance. |
||
83 | * |
||
84 | * @return FormTypeInterface |
||
85 | */ |
||
86 | abstract protected function getTestedInstance(); |
||
87 | } |
||
88 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..