3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-22 05:08:05 +00:00
Files
snipe-it/tests/Feature/Users/Ui/CloneUserTest.php
2026-07-10 14:41:47 +01:00

34 lines
1021 B
PHP

<?php
namespace Tests\Feature\Users\Ui;
use App\Models\Company;
use App\Models\User;
use Tests\TestCase;
class CloneUserTest extends TestCase
{
public function test_page_renders()
{
$this->actingAs(User::factory()->superuser()->create())
->get(route('users.clone.show', User::factory()->create()))
->assertOk();
}
public function test_clone_prepopulates_all_companies_for_multi_company_user()
{
[$companyA, $companyB] = Company::factory()->count(2)->create();
$user = User::factory()->forCompany($companyA->id)->create();
$user->companies()->sync([$companyA->id, $companyB->id]);
$response = $this->actingAs(User::factory()->superuser()->create())
->get(route('users.clone.show', $user))
->assertOk();
// Both company IDs should be pre-selected in the form.
$response->assertSee('value="'.$companyA->id.'"', false);
$response->assertSee('value="'.$companyB->id.'"', false);
}
}