FormBench   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 60
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B setUp() 0 24 1
A create_form() 0 5 1
A create_submit_form() 0 18 1
1
<?php
2
3
namespace Psi\Component\ContentType\Benchmark;
4
5
use Psi\Component\ContentType\Tests\Functional\BaseTestCase;
6
use Psi\Component\ContentType\Tests\Functional\Example\Model\Article;
7
8
/**
9
 * @BeforeMethods({"setUp"})
10
 * @Revs(500)
11
 * @Iterations(10)
12
 * @OutputTimeUnit("milliseconds", precision=2)
13
 */
14
class FormBench extends BaseTestCase
15
{
16
    private $formFactory;
17
18
    public function setUp()
19
    {
20
        $this->formFactory = $this->getContainer([
21
            'mapping' => [
22
                Article::class => [
23
                    'alias' => 'article',
24
                    'properties' => [
25
                        'title' => [
26
                            'type' => 'text',
27
                        ],
28
                        'image' => [
29
                            'type' => 'image',
30
                        ],
31
                        'slideshow' => [
32
                            'type' => 'collection',
33
                            'options' => [
34
                                'field_type' => 'image',
35
                            ],
36
                        ],
37
                    ],
38
                ],
39
            ],
40
        ])->get('symfony.form_factory');
41
    }
42
43
    /**
44
     * @Subject()
45
     */
46
    public function create_form()
47
    {
48
        $builder = $this->formFactory->createBuilder(Article::class);
49
        $builder->getForm();
50
    }
51
52
    /**
53
     * @Subject()
54
     */
55
    public function create_submit_form()
56
    {
57
        $builder = $this->formFactory->createBuilder(Article::class);
58
        $form = $builder->getForm();
59
        $imageData = [
60
            'height' => 100,
61
            'width' => 100,
62
            'mimetype' => 'image/jpeg',
63
            'path' => 'path/to/foo.png',
64
        ];
65
66
        $data = [
67
            'title' => 'Hello',
68
            'image' => $imageData,
69
        ];
70
71
        $form->submit($data);
72
    }
73
}
74