From a43e6c12a0c200ac6534aa190323466d64d485e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 26 Jun 2021 11:08:26 +0200 Subject: [PATCH] add tests for UserApiController --- .../Controller/UserApiControllerTest.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php new file mode 100644 index 000000000..85d9895fc --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -0,0 +1,49 @@ +getClientAuthenticated(); + + $client->request(Request::METHOD_GET, '/api/1.0/main/user.json'); + + $this->assertResponseIsSuccessful(); + + $data = \json_decode($client->getResponse()->getContent(), true); + $this->assertTrue(\array_key_exists('count', $data)); + $this->assertGreaterThan(0, $data['count']); + $this->assertTrue(\array_key_exists('results', $data)); + + return $data['results'][0]; + } + + /** + * @depends testIndex + */ + public function testEntity($existingUser) + { + $client = $this->getClientAuthenticated(); + + $client->request(Request::METHOD_GET, '/api/1.0/main/user/'.$existingUser['id'].'.json'); + + $this->assertResponseIsSuccessful(); + } + + public function testWhoami() + { + $client = $this->getClientAuthenticated(); + + $client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json'); + + $this->assertResponseIsSuccessful(); + } +}