mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
added it_create_new_user_with_avatar test
This commit is contained in:
@@ -8,8 +8,10 @@ use App\Models\User;
|
||||
use App\Notifications\ResetPassword;
|
||||
use DB;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Notification;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminTest extends TestCase
|
||||
@@ -121,7 +123,6 @@ class AdminTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -267,4 +268,41 @@ class AdminTest extends TestCase
|
||||
|
||||
$this->assertTrue(User::find($user->id)->role === 'admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_create_new_user_with_avatar()
|
||||
{
|
||||
Storage::fake('local');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$avatar = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$this->postJson("/api/admin/users/create", [
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'VerySecretPassword',
|
||||
'storage_capacity' => 15,
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com'
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'name' => 'John Doe'
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(User::whereEmail('john@doe.com')->first()->settings->getRawOriginal('avatar'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user