test refactoring

This commit is contained in:
Čarodej
2022-01-13 11:41:40 +01:00
parent 6cf7e5d26d
commit 66de377657
14 changed files with 82 additions and 50 deletions

View File

@@ -139,9 +139,14 @@ class UserAccountTest extends TestCase
'id' => (string) $user->id,
'type' => 'user',
'attributes' => [
'avatar' => null,
'avatar' => [
'md' => 'http://localhost/assets/images/default-avatar.png',
'sm' => 'http://localhost/assets/images/default-avatar.png',
'xs' => 'http://localhost/assets/images/default-avatar.png',
],
'email' => $user->email,
'role' => $user->role,
'socialite_account' => false,
'two_factor_authentication' => false,
'folders' => [],
'storage' => [
@@ -151,9 +156,21 @@ class UserAccountTest extends TestCase
'capacity_formatted' => '1GB',
],
'created_at' => format_date($user->created_at, '%d. %b. %Y'),
'updated_at' => format_date($user->updated_at, '%d. %b. %Y'),
'updated_at' => format_date($user->updated_at, '%d. %B. %Y'),
],
'meta' => [
'restrictions' => [
'canCreateFolder' => true,
'canCreateTeamFolder' => true,
'canDownload' => true,
'canInviteTeamMembers' => true,
'canUpload' => true,
],
],
'relationships' => [
'creditCards' => [
'data' => [],
],
'settings' => [
'data' => [
'id' => (string) $user->id,
@@ -174,13 +191,6 @@ class UserAccountTest extends TestCase
'favourites' => [
'data' => [],
],
'limitations' => [
'id' => $user->id,
'type' => 'limitations',
'data' => [
'attributes' => $user->limitations,
],
],
],
],
]);

View File

@@ -131,6 +131,14 @@ class AdminTest extends TestCase
'used' => '1.00MB',
'percentage' => 0.1,
],
'traffic' => [
'chart' => [
'download' => [],
'upload' => [],
],
'download' => '0B',
'upload' => '0B',
],
],
],
]);

View File

@@ -3,7 +3,6 @@ namespace Tests\Domain\Admin;
use Tests\TestCase;
use App\Users\Models\User;
use Laravel\Sanctum\Sanctum;
use Domain\Files\Models\File;
class DashboardTest extends TestCase
@@ -25,11 +24,26 @@ class DashboardTest extends TestCase
->getJson('/api/admin/dashboard')
->assertStatus(200)
->assertExactJson([
'license' => 'extended',
'total_premium_users' => 0,
'app_version' => config('vuefilemanager.version'),
'total_users' => 1,
'total_used_space' => '2.00MB',
'app' => [
'earnings' => '$0.00',
'license' => 'extended',
'version' => config('vuefilemanager.version'),
],
'disk' => [
'download' => [
'records' => [],
'total' => '0B',
],
'upload' => [
'records' => [],
'total' => '0B',
],
'used' => '2.00MB',
],
'users' => [
'total' => 1,
'usersPremiumTotal' => 0,
],
]);
}
@@ -39,20 +53,21 @@ class DashboardTest extends TestCase
public function it_get_new_users_for_dashboard()
{
$users = User::factory()
->count(5)
->count(3)
->create(['role' => 'user']);
$admin = User::factory()
->create(['role' => 'admin']);
Sanctum::actingAs($admin);
$users->each(function ($user) {
$this->getJson('/api/admin/dashboard/newbies')
$users->each(
fn ($user) =>
$this
->actingAs($admin)
->getJson('/api/admin/dashboard/newbies')
->assertStatus(200)
->assertJsonFragment([
'id' => $user->id,
]);
});
])
);
}
}

View File

@@ -1,5 +1,4 @@
<?php
namespace Tests\Domain\Settings;
use Storage;

View File

@@ -1,5 +1,4 @@
<?php
namespace Tests\Support\Scheduler;
use Storage;