|
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
|
|
|
|