Completed
Push — master ( 5507ff...622aad )
by Serhii
01:49
created

EmployeesControllerTest::getFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 35
rs 9.36
c 0
b 0
f 0
1
<?php
2
3
namespace App\Tests\Functional\Controller;
4
5
class EmployeesControllerTest extends AbstractController
6
{
7
    public function testGetEmployees()
8
    {
9
        $this->restRequest('/api/employees');
10
    }
11
12
    public function testGetEmployeesSlug()
13
    {
14
        $slug = $this->getEm()->getRepository('App:Employee')->findOneBy([])->getSlug();
15
        $this->restRequest('/api/employees/'.$slug);
16
        $this->restRequest('/api/employees/nonexistent-slug', 'GET', 404);
17
    }
18
19
    public function testGetEmployeesSlugRoles()
20
    {
21
        $slug = $this->getEm()->getRepository('App:Employee')->findOneBy([])->getSlug();
22
        $this->restRequest('/api/employees/'.$slug.'/roles');
23
        $this->restRequest('/api/employees/nonexistent-slug/roles', 'GET', 404);
24
    }
25
26 View Code Duplication
    public function testEmployeesResponseFields()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $this->restRequest('/api/employees');
29
30
        $content = $this->getSessionClient()->getResponse()->getContent();
31
        foreach ($this->getFields() as $field) {
32
            $this->assertContains($field, $content);
33
        }
34
    }
35
36
    public function getFields()
37
    {
38
        return [
39
            'employees',
40
            'first_name',
41
            'last_name',
42
            'dob',
43
            'position',
44
            'biography',
45
            'slug',
46
            'avatar',
47
            'reference',
48
            'employee_small',
49
            'employee_big',
50
            'url',
51
            'properties',
52
            'alt',
53
            'title',
54
            'src',
55
            'width',
56
            'height',
57
            'created_at',
58
            'updated_at',
59
            'page',
60
            'count',
61
            'total_count',
62
            '_links',
63
            'self',
64
            'first',
65
            'prev',
66
            'next',
67
            'last',
68
            'href',
69
        ];
70
    }
71
}
72