Completed
Push — master ( 3cd231...d48ef1 )
by
unknown
153:58 queued 132:33
created

CheckboxPagePartAdminTypeTest::testFormType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 28

Duplication

Lines 28
Ratio 100 %

Importance

Changes 0
Metric Value
dl 28
loc 28
rs 9.472
c 0
b 0
f 0
nc 2
cc 2
nop 0
1
<?php
2
3
namespace Kunstmaan\FormBundle\Tests\Form;
4
5
use Kunstmaan\FormBundle\Entity\PageParts\CheckboxPagePart;
6
use Kunstmaan\FormBundle\Form\CheckboxPagePartAdminType;
7
use Symfony\Component\Form\Test\TypeTestCase;
8
9
/**
10
 * Class CheckboxPagePartAdminTypeTest
11
 */
12 View Code Duplication
class CheckboxPagePartAdminTypeTest extends TypeTestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
13
{
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