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

NonAbstractFormPageAdminType::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 1
1
<?php
2
3
namespace Kunstmaan\FormBundle\Tests\Form;
4
5
use Kunstmaan\FormBundle\Entity\AbstractFormPage;
6
use Kunstmaan\FormBundle\Form\AbstractFormPageAdminType;
7
use Symfony\Component\Form\Test\TypeTestCase;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
class NonAbstractFormPageAdminType extends AbstractFormPageAdminType
11
{
12
    public function configureOptions(OptionsResolver $resolver)
13
    {
14
        parent::configureOptions($resolver);
15
        $resolver->setDefaults(array(
16
            'data_class' => 'Kunstmaan\FormBundle\Tests\Form\FormPage',
17
        ));
18
    }
19
}
20
21
class FormPage extends AbstractFormPage
0 ignored issues
show
Coding Style Compatibility introduced by Kevin Jossart
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
22
{
23
    public function getPossibleChildTypes()
24
    {
25
        return null;
26
    }
27
    public function getPagePartAdminConfigurations()
28
    {
29
        return [
30
            [
31
                'name'  => 'ContentPage',
32
                'class' => '{{ namespace }}\Entity\Pages\ContentPage'
33
            ],
34
            [
35
                'name'  => 'FormPage',
36
                'class' => '{{ namespace }}\Entity\Pages\FormPage'
37
            ]
38
        ];
39
    }
40
    public function getDefaultView()
41
    {
42
        return 'some.twig';
43
    }
44
}
45
46
/**
47
 * Generated by PHPUnit_SkeletonGenerator on 2012-09-20 at 15:14:43.
48
 */
49
class AbstractFormPageAdminTypeTest extends TypeTestCase
0 ignored issues
show
Coding Style Compatibility introduced by Ruud Denivel
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
50
{
51
    public function testFormType()
52
    {
53
        $formData = [
54
            'title' => 'Testing!',
55
            'thanks' => 'Cheers',
56
            'subject' => 'Thanks a lot',
57
            'from_email' => '[email protected]',
58
            'to_email' => '[email protected]',
59
        ];
60
        $form = $this->factory->create(NonAbstractFormPageAdminType::class);
61
62
        $formPage = new FormPage();
63
        $formPage->setTitle('Testing!');
64
        $formPage->setThanks('<p>Cheers</p>');
65
        $formPage->setSubject('Thanks a lot');
66
        $formPage->setFromEmail('[email protected]');
67
        $formPage->setToEmail('[email protected]');
68
69
        $form->submit($formData);
70
71
        $this->assertTrue($form->isSynchronized());
72
        $this->assertTrue($form->isValid());
73
        $this->assertEquals($formPage, $form->getData());
74
75
        $view = $form->createView();
76
        $children = $view->children;
77
78
        foreach (array_keys($formData) as $key) {
79
            $this->assertArrayHasKey($key, $children);
80
        }
81
    }
82
}
83