Conditions | 1 |
Paths | 1 |
Total Lines | 31 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function testSetUserEmail_() |
||
19 | { |
||
20 | $userDetails = [ |
||
21 | 'email' => '[email protected]', |
||
22 | 'name' => 'Hello', |
||
23 | 'password' => 'secret', |
||
24 | ]; |
||
25 | |||
26 | // get the logged in user (create one if no one is logged in) |
||
27 | $this->registerAndLoginTestingUser($userDetails); |
||
28 | |||
29 | $data = [ |
||
30 | 'email' => '[email protected]', |
||
31 | ]; |
||
32 | |||
33 | // mock sending real emails |
||
34 | $confirmEmail = $this->mock(ConfirmEmail::class); |
||
35 | $confirmEmail->shouldReceive('send')->once()->withAnyArgs()->andReturn(true); |
||
36 | $confirmEmail->shouldReceive('to')->once()->withAnyArgs()->andReturn($confirmEmail); |
||
37 | |||
38 | // send the HTTP request |
||
39 | $response = $this->apiCall($this->endpoint, 'post', $data, true); |
||
40 | |||
41 | // assert response status is correct |
||
42 | $this->assertEquals($response->getStatusCode(), '202'); |
||
43 | |||
44 | $this->assertResponseContainKeyValue(['message' => 'User Email Saved Successfully.'], $response); |
||
45 | |||
46 | $this->seeInDatabase('users', ['email' => $data['email']]); |
||
47 | |||
48 | } |
||
49 | |||
51 |