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

MultiLineTextPagePartAdminTypeTest::testFormType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 32

Duplication

Lines 32
Ratio 100 %

Importance

Changes 0
Metric Value
dl 32
loc 32
rs 9.408
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\MultiLineTextPagePart;
6
use Kunstmaan\FormBundle\Form\MultiLineTextPagePartAdminType;
7
use Symfony\Component\Form\Test\TypeTestCase;
8
9
/**
10
 * Class MultiLineTextPagePartAdminTypeTest
11
 */
12 View Code Duplication
class MultiLineTextPagePartAdminTypeTest 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' => 'type in this box!',
19
            'errormessage_required' => 'fill in the form',
20
            'regex' => '#\w+#',
21
            'errormessage_regex' => 'oops',
22
        ];
23
24
        $form = $this->factory->create(MultiLineTextPagePartAdminType::class);
25
26
        $object = new MultiLineTextPagePart();
27
        $object->setRequired(false);
28
        $object->setErrorMessageRequired('fill in the form');
29
        $object->setLabel('type in this box!');
30
        $object->setRegex('#\w+#');
31
        $object->setErrorMessageRegex('oops');
32
33
        $form->submit($formData);
34
35
        $this->assertTrue($form->isSynchronized());
36
        $this->assertTrue($form->isValid());
37
        $this->assertEquals($object, $form->getData());
38
39
        $view = $form->createView();
40
        $children = $view->children;
41
42
        foreach (array_keys($formData) as $key) {
43
            $this->assertArrayHasKey($key, $children);
44
        }
45
    }
46
}
47