Update php tests

This commit is contained in:
Bubka 2023-12-05 16:32:20 +01:00
parent 4685e23fdb
commit eaaefc1f1b
5 changed files with 23 additions and 24 deletions

View File

@ -43,11 +43,14 @@ public function test_show_existing_user_when_authenticated_returns_success()
$response = $this->actingAs($this->user, 'api-guard')
->json('GET', '/api/v1/user')
->assertOk()
->assertExactJson([
'name' => $this->user->name,
'id' => $this->user->id,
'email' => $this->user->email,
'is_admin' => $this->user->is_admin,
->assertJsonFragment([
'name' => $this->user->name,
'id' => $this->user->id,
'email' => $this->user->email,
'is_admin' => $this->user->is_admin,
])
->assertJsonStructure([
'preferences',
]);
}

View File

@ -63,7 +63,7 @@ public function test_fetch_logo_returns_filename()
{
$response = $this->actingAs($this->user, 'api-guard')
->json('POST', '/api/v1/icons/default', [
'service' => 'abode',
'service' => 'dropbox',
])
->assertStatus(201)
->assertJsonStructure([

View File

@ -91,7 +91,7 @@ public function test_user_login_with_uppercased_email_returns_success()
*
* @covers \App\Http\Middleware\SkipIfAuthenticated
*/
public function test_user_login_already_authenticated_returns_success()
public function test_user_login_already_authenticated_is_rejected()
{
$response = $this->json('POST', '/user/login', [
'email' => $this->user->email,
@ -103,10 +103,9 @@ public function test_user_login_already_authenticated_returns_success()
'email' => $this->user->email,
'password' => self::PASSWORD,
])
->assertStatus(200)
->assertJson([
'message' => 'authenticated',
'name' => $this->user->name,
->assertStatus(400)
->assertJsonStructure([
'message',
]);
}

View File

@ -53,11 +53,14 @@ public function test_update_user_returns_success()
'password' => self::PASSWORD,
])
->assertOk()
->assertExactJson([
->assertJsonFragment([
'name' => self::NEW_USERNAME,
'id' => $this->user->id,
'email' => self::NEW_EMAIL,
'is_admin' => false,
])
->assertJsonStructure([
'preferences',
]);
$this->assertDatabaseHas('users', [
@ -80,7 +83,7 @@ public function test_update_user_without_changing_email_returns_success()
'password' => self::PASSWORD,
])
->assertOk()
->assertExactJson([
->assertJsonFragment([
'name' => self::NEW_USERNAME,
'id' => $this->user->id,
'email' => $this->user->email,
@ -107,7 +110,7 @@ public function test_update_user_without_changing_name_returns_success()
'password' => self::PASSWORD,
])
->assertOk()
->assertExactJson([
->assertJsonFragment([
'name' => $this->user->name,
'id' => $this->user->id,
'email' => self::NEW_EMAIL,
@ -134,7 +137,7 @@ public function test_update_user_with_uppercased_email_returns_success()
'password' => self::PASSWORD,
])
->assertOk()
->assertExactJson([
->assertJsonFragment([
'name' => self::NEW_USERNAME,
'id' => $this->user->id,
'email' => self::NEW_EMAIL,
@ -166,7 +169,7 @@ public function test_update_user_in_demo_mode_returns_unchanged_user()
'password' => self::PASSWORD,
])
->assertOk()
->assertExactJson([
->assertJsonFragment([
'name' => $name,
'id' => $this->user->id,
'email' => $email,

View File

@ -205,7 +205,7 @@ public function test_legacy_login_is_rejected_when_webauthn_only_is_enable()
*
* @covers \App\Http\Middleware\SkipIfAuthenticated
*/
public function test_webauthn_login_already_authenticated_returns_success()
public function test_webauthn_login_already_authenticated_is_rejected()
{
$this->user = User::factory()->create(['email' => self::EMAIL]);
@ -238,15 +238,9 @@ public function test_webauthn_login_already_authenticated_returns_success()
->assertOk();
$this->json('POST', '/webauthn/login', self::ASSERTION_RESPONSE)
->assertOk()
->assertJsonFragment([
'message' => 'authenticated',
'name' => $this->user->name,
])
->assertStatus(400)
->assertJsonStructure([
'message',
'name',
'preferences',
]);
}