|
@@ -179,112 +179,6 @@ class UserTest extends TestCase
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * test User logout via API
|
|
|
- *
|
|
|
- * @test
|
|
|
- */
|
|
|
- public function testGetUserDetails()
|
|
|
- {
|
|
|
- $user = User::find(1);
|
|
|
-
|
|
|
- $response = $this->actingAs($user, 'api')
|
|
|
- ->json('GET', '/api/user')
|
|
|
- ->assertStatus(200)
|
|
|
- ->assertJsonStructure(['name', 'email']);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * test User update with wrong current password via API
|
|
|
- *
|
|
|
- * @test
|
|
|
- */
|
|
|
- public function testUserUpdateWithWrongCurrentPassword()
|
|
|
- {
|
|
|
- $user = User::find(1);
|
|
|
-
|
|
|
- $response = $this->actingAs($user, 'api')
|
|
|
- ->json('PATCH', '/api/user', [
|
|
|
- 'name' => 'userUpdated',
|
|
|
- 'email' => 'userUpdated@example.org',
|
|
|
- 'password' => 'wrongPassword',
|
|
|
- ]);
|
|
|
-
|
|
|
- $response->assertStatus(400)
|
|
|
- ->assertJsonStructure(['message']);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * test User update via API
|
|
|
- *
|
|
|
- * @test
|
|
|
- */
|
|
|
- public function testUserUpdate()
|
|
|
- {
|
|
|
- $user = User::find(1);
|
|
|
-
|
|
|
- $response = $this->actingAs($user, 'api')
|
|
|
- ->json('PATCH', '/api/user', [
|
|
|
- 'name' => 'userUpdated',
|
|
|
- 'email' => 'userUpdated@example.org',
|
|
|
- 'password' => 'password',
|
|
|
- ]);
|
|
|
-
|
|
|
- $response->assertStatus(200)
|
|
|
- ->assertJsonFragment([
|
|
|
- 'username' => 'userUpdated'
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * test User password update with wrong current password via API
|
|
|
- *
|
|
|
- * @test
|
|
|
- */
|
|
|
- public function testUserPasswordUpdateWithWrongCurrentPassword()
|
|
|
- {
|
|
|
- $user = User::find(1);
|
|
|
-
|
|
|
- $response = $this->actingAs($user, 'api')
|
|
|
- ->json('PATCH', '/api/password', [
|
|
|
- 'currentPassword' => 'wrongPassword',
|
|
|
- 'password' => 'passwordUpdated',
|
|
|
- 'password_confirmation' => 'passwordUpdated',
|
|
|
- ]);
|
|
|
-
|
|
|
- $response->assertStatus(400)
|
|
|
- ->assertJsonStructure(['message']);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * test User password update via API
|
|
|
- *
|
|
|
- * @test
|
|
|
- */
|
|
|
- public function testUserPasswordUpdate()
|
|
|
- {
|
|
|
- $user = User::find(1);
|
|
|
-
|
|
|
- $response = $this->actingAs($user, 'api')
|
|
|
- ->json('PATCH', '/api/password', [
|
|
|
- 'currentPassword' => 'password',
|
|
|
- 'password' => 'passwordUpdated',
|
|
|
- 'password_confirmation' => 'passwordUpdated',
|
|
|
- ]);
|
|
|
-
|
|
|
- $response->assertStatus(200)
|
|
|
- ->assertJsonStructure(['message']);
|
|
|
-
|
|
|
- $user->refresh();
|
|
|
-
|
|
|
- $this->assertTrue(Hash::check('passwordUpdated', $user->password));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* test User creation via API
|
|
|
*
|