Conditions | 2 |
Paths | 2 |
Total Lines | 28 |
Lines | 28 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
14 | public function testFormType() |
||
15 | { |
||
16 | $formData = [ |
||
17 | 'required' => false, |
||
18 | 'label' => 'check this box!', |
||
19 | 'errormessage_required' => 'fill in the form', |
||
20 | ]; |
||
21 | |||
22 | $form = $this->factory->create(CheckboxPagePartAdminType::class); |
||
23 | |||
24 | $object = new CheckboxPagePart(); |
||
25 | $object->setRequired(false); |
||
26 | $object->setErrorMessageRequired('fill in the form'); |
||
27 | $object->setLabel('check this box!'); |
||
28 | |||
29 | $form->submit($formData); |
||
30 | |||
31 | $this->assertTrue($form->isSynchronized()); |
||
32 | $this->assertTrue($form->isValid()); |
||
33 | $this->assertEquals($object, $form->getData()); |
||
34 | |||
35 | $view = $form->createView(); |
||
36 | $children = $view->children; |
||
37 | |||
38 | foreach (array_keys($formData) as $key) { |
||
39 | $this->assertArrayHasKey($key, $children); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.