Completed
Push — master ( d5f3e2...f413dd )
by Ivo
02:47
created

BatchTypeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSubmitValidData() 0 30 1
1
<?php
2
3
namespace Ivoaz\Bundle\ContentEditableBundle\Tests\Form\Type;
4
5
use Ivoaz\Bundle\ContentEditableBundle\Form\Model\Batch;
6
use Ivoaz\Bundle\ContentEditableBundle\Form\Model\BatchContent;
7
use Ivoaz\Bundle\ContentEditableBundle\Form\Type\BatchType;
8
use Symfony\Component\Form\Test\TypeTestCase;
9
10
class BatchTypeTest extends TypeTestCase
11
{
12
    public function testSubmitValidData()
13
    {
14
        $formData = [
15
            'contents' => [
16
                [
17
                    'id' => 1,
18
                    'text' => 'Text 1',
19
                ],
20
                [
21
                    'id' => 2,
22
                    'text' => 'Text 2',
23
                ],
24
            ],
25
        ];
26
27
        $form = $this->factory->create(BatchType::class);
28
29
        $object = new Batch();
30
        $object->contents[] = new BatchContent();
31
        $object->contents[] = new BatchContent();
32
        $object->contents[0]->id = 1;
33
        $object->contents[1]->id = 2;
34
        $object->contents[0]->text = 'Text 1';
35
        $object->contents[1]->text = 'Text 2';
36
37
        $form->submit($formData);
38
39
        $this->assertTrue($form->isSynchronized());
40
        $this->assertEquals($object, $form->getData());
41
    }
42
}
43