| Conditions | 1 |
| Paths | 1 |
| Total Lines | 30 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public function testLogin() |
||
| 10 | { |
||
| 11 | $client = static::createClient(); |
||
| 12 | |||
| 13 | $json = '{"email":"[email protected]", |
||
| 14 | "password":"intern1"}'; |
||
| 15 | |||
| 16 | $client->request('POST', '/api/login', [], [], [], $json |
||
| 17 | ); |
||
| 18 | |||
| 19 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
||
| 20 | |||
| 21 | $content = $client->getResponse()->getContent(); |
||
| 22 | |||
| 23 | $arrayContent = json_decode($content, true); |
||
| 24 | |||
| 25 | $token = $arrayContent['X-AUTH-TOKEN']; |
||
| 26 | |||
| 27 | $headers = ['HTTP_X-AUTH-TOKEN' => $token]; |
||
| 28 | |||
| 29 | $client->request('GET', '/api/user', [], [], $headers); |
||
| 30 | |||
| 31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
||
| 32 | |||
| 33 | $headers = ['HTTP_X-AUTH-TOKEN' => null]; |
||
| 34 | |||
| 35 | $client->request('GET', '/api/user', [], [], $headers); |
||
| 36 | |||
| 37 | $this->assertEquals(401, $client->getResponse()->getStatusCode()); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |