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\FormBundle\Tests\Form; |
||
4 | |||
5 | use Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\FileFormSubmissionField; |
||
6 | use Kunstmaan\FormBundle\Form\FileFormSubmissionType; |
||
7 | use Symfony\Component\Form\Test\TypeTestCase; |
||
8 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
||
9 | |||
10 | /** |
||
11 | * Class FileFormSubmissionTypeTest |
||
12 | */ |
||
13 | class FileFormSubmissionTypeTest extends TypeTestCase |
||
14 | { |
||
15 | /** |
||
16 | * @var UploadedFile |
||
17 | */ |
||
18 | private $file; |
||
19 | |||
20 | /** |
||
21 | * @var UploadedFile |
||
22 | */ |
||
23 | private $image; |
||
24 | |||
25 | public function setUp() |
||
26 | { |
||
27 | parent::setUp(); |
||
28 | |||
29 | $this->file = tempnam(sys_get_temp_dir(), 'upl'); // create file |
||
0 ignored issues
–
show
|
|||
30 | |||
31 | imagepng(imagecreatetruecolor(10, 10), $this->file); // create and write image/png to it |
||
32 | |||
33 | $this->image = new UploadedFile( |
||
34 | $this->file, |
||
35 | 'new_image.png' |
||
36 | ); |
||
37 | } |
||
38 | |||
39 | public function testFormType() |
||
40 | { |
||
41 | $formData = [ |
||
42 | 'file' => $this->image, |
||
43 | ]; |
||
44 | |||
45 | $field = new FileFormSubmissionField(); |
||
46 | $field->file = $this->image; |
||
47 | |||
48 | $form = $this->factory->create(FileFormSubmissionType::class, $field); |
||
49 | |||
50 | $form->submit($formData); |
||
51 | |||
52 | $this->assertTrue($form->isSynchronized()); |
||
53 | $this->assertTrue($form->isValid()); |
||
54 | $this->assertEquals($field, $form->getData()); |
||
55 | |||
56 | $view = $form->createView(); |
||
57 | $children = $view->children; |
||
58 | |||
59 | foreach (array_keys($formData) as $key) { |
||
60 | $this->assertArrayHasKey($key, $children); |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 |
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..