Skip to content

Commit

Permalink
🐛 fix UserProfileSettingsResource.php (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Aug 29, 2023
1 parent bd60349 commit 271433d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Http/Resources/UserProfileSettingsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function toArray($request): array {
'privateProfile' => (bool) $this->private_profile,
'preventIndex' => (bool) $this->prevent_index,
'defaultStatusVisibility' => (int) $this->default_status_visibility->value,
'privacyHideDays' => (int) $this->privacy_hide_days->value,
'privacyHideDays' => (int) $this->privacy_hide_days,
'password' => (bool) $this->password,
'email' => $this->email,
'emailVerified' => !empty($this->email_verified_at),
Expand Down
33 changes: 33 additions & 0 deletions tests/Feature/APIv1/SettingsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Tests\Feature\APIv1;

use App\Models\User;
use App\Providers\AuthServiceProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\ApiTestCase;

class SettingsTest extends ApiTestCase
{

use RefreshDatabase;

public function testGetProfileSettings(): void {
$user = User::factory()->create();
$userToken = $user->createToken('token', array_keys(AuthServiceProvider::$scopes))->accessToken;

$response = $this->get(
uri: '/api/v1/settings/profile',
headers: ['Authorization' => 'Bearer ' . $userToken]
);
$response->assertOk();
$response->assertJsonStructure([
'data' => [
'username',
'displayName',
'profilePicture',
//...
]
]);
}
}

0 comments on commit 271433d

Please sign in to comment.