From 84dfcb28990c73bfdd91653f7541094b5540f171 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 1 Nov 2021 16:01:21 +0100 Subject: [PATCH] tests for GET and POST: attempt --- .../RelationshipApiControllerTest.php | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php new file mode 100644 index 000000000..6d538a646 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -0,0 +1,74 @@ +client = static::createClient(array(), array( + 'PHP_AUTH_USER' => 'fred', + 'PHP_AUTH_PW' => 'password', + )); + } + + /** + * @dataProvider personProvider + */ + public function testGetRelationshipByPerson($personId) + { + $this->client->request(Request::METHOD_GET, sprintf('/api/1.0/relations/relationship/by-person/%d.json', $personId)); + + $response = $this->client->getResponse(); + $this->assertEquals(200, $response->getStatusCode(), 'Test to see that API response returns a status code 200'); + } + + /** + * @dataProvider relationProvider + */ + + public function testPostRelationship($fromPersonId, $toPersonId, $relationId, $isReverse): void + { + $this->client->request(Request::METHOD_POST, + '/api/1.0/person/relations/relationship.json', + [], + [], + [], + \json_encode([ + 'type' => 'relationship', + 'fromPerson' => ['id' => $fromPersonId, 'type' => 'person'], + 'toPerson' => ['id' => $toPersonId, 'type' => 'person'], + 'relation' => ['id' => $relationId, 'type' => 'relation'], + 'reverse' => $isReverse + ])); + + $response = $this->client->getResponse(); + $this->assertEquals(200, $response->getStatusCode()); + } + + public function relationProvider(): array + { + //TODO: which different cases to test? + return [ + [333, 334, 1, true], + ]; + + } + + public function personProvider(): array + { + //TODO: which different cases to test? + return [ + [333], + ]; + } +} \ No newline at end of file