assertUrlIsSecured('/api/projects'); } public function testGetCollection() { $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $this->assertAccessIsGranted($client, '/api/projects'); $result = json_decode($client->getResponse()->getContent(), true); $this->assertInternalType('array', $result); $this->assertNotEmpty($result); $this->assertEquals(1, count($result)); $this->assertStructure($result[0]); } public function testGetEntity() { $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); $this->assertAccessIsGranted($client, '/api/projects/1'); $result = json_decode($client->getResponse()->getContent(), true); $this->assertInternalType('array', $result); $this->assertStructure($result); } public function testNotFound() { $this->assertEntityNotFound(User::ROLE_USER, '/api/projects/2'); } protected function assertStructure(array $result) { $expectedKeys = [ 'id', 'name', 'comment', 'visible', 'budget', 'order_number', 'customer_id' ]; $actual = array_keys($result); $this->assertEquals(count($expectedKeys), count($actual), 'Project entity has different amount of keys'); $this->assertEquals($expectedKeys, $actual, 'Project structure does not match'); } }