| @@ 48-65 (lines=18) @@ | ||
| 45 | $this->assertResponseContainKeys(['id', 'token'], $response); |
|
| 46 | } |
|
| 47 | ||
| 48 | public function testUserLoginExistingUserUsingGetRequest_() |
|
| 49 | { |
|
| 50 | $data = [ |
|
| 51 | 'email' => '[email protected]', |
|
| 52 | 'password' => 'secret', |
|
| 53 | ]; |
|
| 54 | ||
| 55 | // send the HTTP request |
|
| 56 | $response = $this->apiCall($this->endpoint, 'get', $data, false); |
|
| 57 | ||
| 58 | // assert response status is correct |
|
| 59 | $this->assertEquals('405', $response->getStatusCode()); |
|
| 60 | ||
| 61 | // assert message is correct |
|
| 62 | $this->assertResponseContainKeyValue([ |
|
| 63 | 'message' => '405 Method Not Allowed', |
|
| 64 | ], $response); |
|
| 65 | } |
|
| 66 | ||
| 67 | public function testUserLoginNonExistingUser_() |
|
| 68 | { |
|
| @@ 67-84 (lines=18) @@ | ||
| 64 | ], $response); |
|
| 65 | } |
|
| 66 | ||
| 67 | public function testUserLoginNonExistingUser_() |
|
| 68 | { |
|
| 69 | $data = [ |
|
| 70 | 'email' => '[email protected]', |
|
| 71 | 'password' => 'secret', |
|
| 72 | ]; |
|
| 73 | ||
| 74 | // send the HTTP request |
|
| 75 | $response = $this->apiCall($this->endpoint, 'post', $data, false); |
|
| 76 | ||
| 77 | // assert response status is correct |
|
| 78 | $this->assertEquals('401', $response->getStatusCode()); |
|
| 79 | ||
| 80 | // assert message is correct |
|
| 81 | $this->assertResponseContainKeyValue([ |
|
| 82 | 'message' => 'Credentials Incorrect.', |
|
| 83 | ], $response); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function testUserLoginExistingUserWithoutEmail_() |
|
| 87 | { |
|
| @@ 49-67 (lines=19) @@ | ||
| 46 | $this->seeInDatabase('users', ['email' => $data['email']]); |
|
| 47 | } |
|
| 48 | ||
| 49 | public function testRegisterNewUserUsingGetVerb() |
|
| 50 | { |
|
| 51 | $data = [ |
|
| 52 | 'email' => '[email protected]', |
|
| 53 | 'name' => 'Hello', |
|
| 54 | 'password' => 'secret', |
|
| 55 | ]; |
|
| 56 | ||
| 57 | // send the HTTP request |
|
| 58 | $response = $this->apiCall($this->endpoint, 'get', $data, false); |
|
| 59 | ||
| 60 | // assert response status is correct |
|
| 61 | $this->assertEquals('405', $response->getStatusCode()); |
|
| 62 | ||
| 63 | // assert response contain the correct message |
|
| 64 | $this->assertResponseContainKeyValue([ |
|
| 65 | 'message' => '405 Method Not Allowed', |
|
| 66 | ], $response); |
|
| 67 | } |
|
| 68 | ||
| 69 | public function testRegisterExistingUser() |
|
| 70 | { |
|
| @@ 93-110 (lines=18) @@ | ||
| 90 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 91 | } |
|
| 92 | ||
| 93 | public function testRegisterNewUserWithoutEmail() |
|
| 94 | { |
|
| 95 | $data = [ |
|
| 96 | 'name' => 'Hello', |
|
| 97 | 'password' => 'secret', |
|
| 98 | ]; |
|
| 99 | ||
| 100 | // send the HTTP request |
|
| 101 | $response = $this->apiCall($this->endpoint, 'post', $data, false); |
|
| 102 | ||
| 103 | // assert response status is correct |
|
| 104 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 105 | ||
| 106 | // assert response contain the correct message |
|
| 107 | $this->assertValidationErrorContain($response, [ |
|
| 108 | 'email' => 'The email field is required.', |
|
| 109 | ]); |
|
| 110 | } |
|
| 111 | ||
| 112 | public function testRegisterNewUserWithoutName() |
|
| 113 | { |
|
| @@ 112-129 (lines=18) @@ | ||
| 109 | ]); |
|
| 110 | } |
|
| 111 | ||
| 112 | public function testRegisterNewUserWithoutName() |
|
| 113 | { |
|
| 114 | $data = [ |
|
| 115 | 'email' => '[email protected]', |
|
| 116 | 'password' => 'secret', |
|
| 117 | ]; |
|
| 118 | ||
| 119 | // send the HTTP request |
|
| 120 | $response = $this->apiCall($this->endpoint, 'post', $data, false); |
|
| 121 | ||
| 122 | // assert response status is correct |
|
| 123 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 124 | ||
| 125 | // assert response contain the correct message |
|
| 126 | $this->assertValidationErrorContain($response, [ |
|
| 127 | 'name' => 'The name field is required.', |
|
| 128 | ]); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function testRegisterNewUserWithoutPassword() |
|
| 132 | { |
|
| @@ 131-147 (lines=17) @@ | ||
| 128 | ]); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function testRegisterNewUserWithoutPassword() |
|
| 132 | { |
|
| 133 | $data = [ |
|
| 134 | 'email' => '[email protected]', |
|
| 135 | 'name' => 'Hello', |
|
| 136 | ]; |
|
| 137 | ||
| 138 | $response = $this->apiCall($this->endpoint, 'post', $data, false); |
|
| 139 | ||
| 140 | // assert response status is correct |
|
| 141 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 142 | ||
| 143 | // assert response contain the correct message |
|
| 144 | $this->assertValidationErrorContain($response, [ |
|
| 145 | 'password' => 'The password field is required.', |
|
| 146 | ]); |
|
| 147 | } |
|
| 148 | ||
| 149 | public function testRegisterNewUserWithInvalidEmail() |
|
| 150 | { |
|
| @@ 149-167 (lines=19) @@ | ||
| 146 | ]); |
|
| 147 | } |
|
| 148 | ||
| 149 | public function testRegisterNewUserWithInvalidEmail() |
|
| 150 | { |
|
| 151 | $data = [ |
|
| 152 | 'email' => 'missing-at.dev', |
|
| 153 | 'name' => 'Hello', |
|
| 154 | 'password' => 'secret', |
|
| 155 | ]; |
|
| 156 | ||
| 157 | // send the HTTP request |
|
| 158 | $response = $this->apiCall($this->endpoint, 'post', $data, false); |
|
| 159 | ||
| 160 | // assert response status is correct |
|
| 161 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 162 | ||
| 163 | // assert response contain the correct message |
|
| 164 | $this->assertValidationErrorContain($response, [ |
|
| 165 | 'email' => 'The email must be a valid email address.', |
|
| 166 | ]); |
|
| 167 | } |
|
| 168 | } |
|
| 169 | ||
| @@ 43-58 (lines=16) @@ | ||
| 40 | $this->assertEquals($data['name'], $responseObject->data->name); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function testCreateRoleWithWrongName_() |
|
| 44 | { |
|
| 45 | $this->getTestingAdmin(); |
|
| 46 | ||
| 47 | $data = [ |
|
| 48 | 'name' => 'include space', |
|
| 49 | 'display_name' => 'manager', |
|
| 50 | 'description' => 'he manages things', |
|
| 51 | ]; |
|
| 52 | ||
| 53 | // send the HTTP request |
|
| 54 | $response = $this->apiCall($this->endpoint, 'post', $data, true); |
|
| 55 | ||
| 56 | // assert response status is correct |
|
| 57 | $this->assertEquals('422', $response->getStatusCode()); |
|
| 58 | } |
|
| 59 | ||
| 60 | } |
|
| 61 | ||