Completed
Push — master ( a80802...7141a9 )
by Serhii
13s queued 10s
created

PerformanceEventsControllerTest::getEntityFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Tests\Functional\Controller;
4
5
class PerformanceEventsControllerTest extends AbstractController
6
{
7
    public function testGetPerformanceEvents()
8
    {
9
        $this->restRequest('/api/performanceevents');
10
    }
11
12
    public function testGetPerformanceEventsId()
13
    {
14
        $id = $this->getEm()->getRepository('App:PerformanceEvent')->findOneBy([])->getId();
15
        $this->restRequest('/api/performanceevents/'.$id);
16
        $this->restRequest('/api/performanceevents/100500', 'GET', 404);
17
    }
18
19 View Code Duplication
    public function testPerformanceEventsResponseFields()
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...
20
    {
21
        $this->restRequest('/api/performanceevents?fromDate=01-02-2020&toDate=29-02-2020');
22
        $response = json_decode($this->getSessionClient()->getResponse()->getContent(), true);
23
24
        $this->assertEquals(
25
            count($this->getListFields()),
26
            count(array_keys($response))
27
        );
28
29
        foreach ($this->getListFields() as $field) {
30
            $this->assertArrayHasKey($field, $response);
31
        }
32
33
        $firstEntity = array_shift($response['performance_events']);
34
35
        $this->assertEquals(
36
            count($this->getEntityFields()),
37
            count(array_keys($firstEntity))
38
        );
39
40
        foreach ($this->getEntityFields() as $field) {
41
            $this->assertArrayHasKey($field, $firstEntity);
42
        }
43
    }
44
45
    private function getEntityFields()
46
    {
47
        return array (
48
            'locale',
49
            'id',
50
            'performance',
51
            'date_time',
52
            'venue',
53
            'year',
54
            'month',
55
            'day',
56
            'time',
57
            'created_at',
58
            'updated_at',
59
        );
60
    }
61
62
    private function getListFields()
63
    {
64
        return array (
65
            'performance_events',
66
            'count',
67
        );
68
    }
69
}
70