Completed
Push — refonte ( 64e01a...7173e3 )
by Arnaud
03:31
created

EditActionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testInvoke() 0 55 1
1
<?php
2
3
namespace LAG\AdminBundle\Tests\AdminBundle\Action;
4
5
use LAG\AdminBundle\Action\Configuration\ActionConfiguration;
6
use LAG\AdminBundle\Controller\EditAction;
7
use LAG\AdminBundle\Action\Responder\EditResponder;
8
use LAG\AdminBundle\Admin\AdminInterface;
9
use LAG\AdminBundle\Tests\AdminTestBase;
10
use LAG\AdminBundle\Tests\Entity\TestSimpleEntity;
11
use Symfony\Component\Form\Extension\Core\Type\FormType;
12
use Symfony\Component\Form\FormFactoryInterface;
13
use Symfony\Component\Form\FormInterface;
14
use Symfony\Component\HttpFoundation\Request;
15
16
class EditActionTest extends AdminTestBase
17
{
18
    public function testInvoke()
19
    {
20
        $entity = new TestSimpleEntity();
21
        $request = new Request([], [], []);
22
    
23
        $actionConfiguration = $this->getMockWithoutConstructor(ActionConfiguration::class);
24
        $actionConfiguration
25
            ->method('getParameter')
26
            ->willReturnMap([
27
                ['form', FormType::class],
28
                ['form_options', []],
29
            ])
30
        ;
31
    
32
        $admin = $this->getMockWithoutConstructor(AdminInterface::class);
33
        $admin
34
            ->expects($this->once())
35
            ->method('getUniqueEntity')
36
            ->willReturn($entity)
37
        ;
38
    
39
        $form = $this->getMockWithoutConstructor(FormInterface::class);
40
        $form
41
            ->method('isSubmitted')
42
            ->willReturn(true)
43
        ;
44
        $form
45
            ->method('isValid')
46
            ->willReturn(true)
47
        ;
48
        
49
        $formFactory = $this->getMockWithoutConstructor(FormFactoryInterface::class);
50
        $formFactory
51
            ->expects($this->once())
52
            ->method('create')
53
            ->with(FormType::class, $entity, [])
54
            ->willReturn($form)
55
        ;
56
    
57
        $responder = $this->getMockWithoutConstructor(EditResponder::class);
58
        $responder
59
            ->method('respond')
60
            ->with($actionConfiguration, $admin, $form, null)
61
        ;
62
        
63
        $action = new EditAction(
64
            'edit',
65
            $formFactory,
66
            $responder
67
        );
68
        $action->setConfiguration($actionConfiguration);
69
        $action->setAdmin($admin);
70
        
71
        $action->__invoke($request);
72
    }
73
}
74