AdminEmployeeControllerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmployeeListAction() 0 9 1
A testEmployeeCreateAction() 0 8 1
A testEmployeeDeleteAction() 0 17 1
1
<?php
2
3
namespace App\Tests\Functional\Controller;
4
5
class AdminEmployeeControllerTest extends AbstractAdminController
6
{
7
    public function testEmployeeListAction()
8
    {
9
        $this->request('/admin/Employee/list', 'GET', 302);
10
11
        $this->logIn();
12
13
        $this->request('/admin/Employee/list', 'GET', 200);
14
        $this->assertAdminListPageHasColumns(['Avatar', 'First Name', 'Last Name', 'Dob', 'Position', 'Roles']);
15
    }
16
17
    public function testEmployeeCreateAction()
18
    {
19
        $this->request('/admin/Employee/create', 'GET', 302);
20
21
        $this->logIn();
22
23
        $this->request('/admin/Employee/create', 'GET', 200);
24
    }
25
26
    public function testEmployeeDeleteAction()
27
    {
28
        $employee = $this->getEm()->getRepository('App:Employee')->findOneBy([]);
29
30
        $employeeCount1 = count($this->getEm()->getRepository('App:Employee')->findAll());
31
        $rolesCount1 = count($this->getEm()->getRepository('App:Role')->findAll());
32
        $employeeRolesCount = $employee->getRoles()->count();
33
34
        $this->processDeleteAction($employee);
35
36
        $rolesCount2 = count($this->getEm()->getRepository('App:Role')->findAll());
37
        $employeeCount2 = count($this->getEm()->getRepository('App:Employee')->findAll());
38
39
        $this->assertEquals($employeeCount1 - 1, $employeeCount2);
40
        // All employees roles must be deleted
41
        $this->assertEquals($rolesCount1 - $employeeRolesCount, $rolesCount2);
42
    }
43
}
44