| @@ 88-112 (lines=25) @@ | ||
| 85 | ], $response); |
|
| 86 | } |
|
| 87 | ||
| 88 | public function testUserLoginExistingUserWithoutEmail_() |
|
| 89 | { |
|
| 90 | $userDetails = [ |
|
| 91 | 'email' => '[email protected]', |
|
| 92 | 'name' => 'Hello', |
|
| 93 | 'password' => 'secret', |
|
| 94 | ]; |
|
| 95 | ||
| 96 | $this->getTestingUser($userDetails); |
|
| 97 | ||
| 98 | $data = [ |
|
| 99 | 'password' => $userDetails['password'], |
|
| 100 | ]; |
|
| 101 | ||
| 102 | // send the HTTP request |
|
| 103 | $response = $this->makeCall($data); |
|
| 104 | ||
| 105 | // assert response status is correct |
|
| 106 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 107 | ||
| 108 | // assert message is correct |
|
| 109 | $this->assertValidationErrorContain($response, [ |
|
| 110 | 'email' => 'The email field is required.', |
|
| 111 | ]); |
|
| 112 | } |
|
| 113 | ||
| 114 | public function testUserLoginExistingUserWithoutPassword_() |
|
| 115 | { |
|
| @@ 114-138 (lines=25) @@ | ||
| 111 | ]); |
|
| 112 | } |
|
| 113 | ||
| 114 | public function testUserLoginExistingUserWithoutPassword_() |
|
| 115 | { |
|
| 116 | $userDetails = [ |
|
| 117 | 'email' => '[email protected]', |
|
| 118 | 'name' => 'Hello', |
|
| 119 | 'password' => 'secret', |
|
| 120 | ]; |
|
| 121 | ||
| 122 | $this->getTestingUser($userDetails); |
|
| 123 | ||
| 124 | $data = [ |
|
| 125 | 'email' => $userDetails['email'], |
|
| 126 | ]; |
|
| 127 | ||
| 128 | // send the HTTP request |
|
| 129 | $response = $this->makeCall($data); |
|
| 130 | ||
| 131 | // assert response status is correct |
|
| 132 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 133 | ||
| 134 | // assert message is correct |
|
| 135 | $this->assertValidationErrorContain($response, [ |
|
| 136 | 'password' => 'The password field is required.', |
|
| 137 | ]); |
|
| 138 | } |
|
| 139 | ||
| 140 | public function testUserLoginExistingUserWithoutEmailAndPassword_() |
|
| 141 | { |
|
| @@ 140-163 (lines=24) @@ | ||
| 137 | ]); |
|
| 138 | } |
|
| 139 | ||
| 140 | public function testUserLoginExistingUserWithoutEmailAndPassword_() |
|
| 141 | { |
|
| 142 | $userDetails = [ |
|
| 143 | 'email' => '[email protected]', |
|
| 144 | 'name' => 'Hello', |
|
| 145 | 'password' => 'secret', |
|
| 146 | ]; |
|
| 147 | ||
| 148 | $this->getTestingUser($userDetails); |
|
| 149 | ||
| 150 | $data = []; // empty data |
|
| 151 | ||
| 152 | // send the HTTP request |
|
| 153 | $response = $this->makeCall($data); |
|
| 154 | ||
| 155 | // assert response status is correct |
|
| 156 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 157 | ||
| 158 | // assert message is correct |
|
| 159 | $this->assertValidationErrorContain($response, [ |
|
| 160 | 'email' => 'The email field is required.', |
|
| 161 | 'password' => 'The password field is required.', |
|
| 162 | ]); |
|
| 163 | } |
|
| 164 | } |
|
| 165 | ||
| @@ 22-45 (lines=24) @@ | ||
| 19 | 'permissions' => 'update-users', |
|
| 20 | ]; |
|
| 21 | ||
| 22 | public function testUpdateExistingUser_() |
|
| 23 | { |
|
| 24 | $user = $this->getTestingUser(); |
|
| 25 | ||
| 26 | $data = [ |
|
| 27 | 'name' => 'Updated Name', |
|
| 28 | 'password' => 'updated#Password', |
|
| 29 | ]; |
|
| 30 | ||
| 31 | // send the HTTP request |
|
| 32 | $response = $this->makeCall($data); |
|
| 33 | ||
| 34 | // assert response status is correct |
|
| 35 | $this->assertEquals('200', $response->getStatusCode()); |
|
| 36 | ||
| 37 | // assert returned user is the updated one |
|
| 38 | $this->assertResponseContainKeyValue([ |
|
| 39 | 'email' => $user->email, |
|
| 40 | 'name' => $data['name'], |
|
| 41 | ], $response); |
|
| 42 | ||
| 43 | // assert data was updated in the database |
|
| 44 | $this->seeInDatabase('users', ['name' => $data['name']]); |
|
| 45 | } |
|
| 46 | ||
| 47 | public function testUpdateExistingUserWithoutData_() |
|
| 48 | { |
|