| @@ 26-50 (lines=25) @@ | ||
| 23 | $this->restRequest('/api/employees/nonexistent-slug/roles', 'GET', 404); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function testEmployeesResponseFields() |
|
| 27 | { |
|
| 28 | $this->restRequest('/api/employees'); |
|
| 29 | $response = json_decode($this->getSessionClient()->getResponse()->getContent(), true); |
|
| 30 | ||
| 31 | $this->assertEquals( |
|
| 32 | count($this->getListFields()), |
|
| 33 | count(array_keys($response)) |
|
| 34 | ); |
|
| 35 | ||
| 36 | foreach ($this->getListFields() as $field) { |
|
| 37 | $this->assertArrayHasKey($field, $response); |
|
| 38 | } |
|
| 39 | ||
| 40 | $firstEntity = array_shift($response['employees']); |
|
| 41 | ||
| 42 | $this->assertEquals( |
|
| 43 | count($this->getEntityFields()), |
|
| 44 | count(array_keys($firstEntity)) |
|
| 45 | ); |
|
| 46 | ||
| 47 | foreach ($this->getEntityFields() as $field) { |
|
| 48 | $this->assertArrayHasKey($field, $firstEntity); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| 52 | private function getEntityFields() |
|
| 53 | { |
|
| @@ 19-43 (lines=25) @@ | ||
| 16 | $this->restRequest('/api/performanceevents/100500', 'GET', 404); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function testPerformanceEventsResponseFields() |
|
| 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 | { |
|
| @@ 45-69 (lines=25) @@ | ||
| 42 | $this->restRequest('/api/performances/nonexistent-slug/performanceevents', 'GET', 404); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function testPerformancesResponseFields() |
|
| 46 | { |
|
| 47 | $this->restRequest('/api/performances'); |
|
| 48 | $response = json_decode($this->getSessionClient()->getResponse()->getContent(), true); |
|
| 49 | ||
| 50 | $this->assertEquals( |
|
| 51 | count($this->getListFields()), |
|
| 52 | count(array_keys($response)) |
|
| 53 | ); |
|
| 54 | ||
| 55 | foreach ($this->getListFields() as $field) { |
|
| 56 | $this->assertArrayHasKey($field, $response); |
|
| 57 | } |
|
| 58 | ||
| 59 | $firstEntity = array_shift($response['performances']); |
|
| 60 | ||
| 61 | $this->assertEquals( |
|
| 62 | count($this->getEntityFields()), |
|
| 63 | count(array_keys($firstEntity)) |
|
| 64 | ); |
|
| 65 | ||
| 66 | foreach ($this->getEntityFields() as $field) { |
|
| 67 | $this->assertArrayHasKey($field, $firstEntity); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| 71 | private function getListFields() |
|
| 72 | { |
|
| @@ 19-44 (lines=26) @@ | ||
| 16 | $this->restRequest('/api/posts/nonexistent-slug', 'GET', 404); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function testPostListResponseFields() |
|
| 20 | { |
|
| 21 | $this->restRequest('/api/posts'); |
|
| 22 | ||
| 23 | $response = json_decode($this->getSessionClient()->getResponse()->getContent(), true); |
|
| 24 | ||
| 25 | $this->assertEquals( |
|
| 26 | count($this->getListFields()), |
|
| 27 | count(array_keys($response)) |
|
| 28 | ); |
|
| 29 | ||
| 30 | foreach ($this->getListFields() as $field) { |
|
| 31 | $this->assertArrayHasKey($field, $response); |
|
| 32 | } |
|
| 33 | ||
| 34 | $firstEntity = array_shift($response['posts']); |
|
| 35 | ||
| 36 | $this->assertEquals( |
|
| 37 | count($this->getEntityFields()), |
|
| 38 | count(array_keys($firstEntity)) |
|
| 39 | ); |
|
| 40 | ||
| 41 | foreach ($this->getEntityFields() as $field) { |
|
| 42 | $this->assertArrayHasKey($field, $firstEntity); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testPinnedPost() |
|
| 47 | { |
|