Spilt test scenarios

This commit is contained in:
Marcus Moore 2025-03-20 16:21:42 -07:00
parent ce585539aa
commit ac56640d40
No known key found for this signature in database

View file

@ -8,26 +8,34 @@ use Tests\TestCase;
class PrintUserInventoryTest extends TestCase
{
public function testPermissionsForPrintAllInventoryPage()
public function testPermissionRequiredToPrintUserInventory()
{
$this->actingAs(User::factory()->create())
->get(route('users.print', User::factory()->create()))
->assertStatus(403);
}
public function testCanPrintUserInventory()
{
$actor = User::factory()->viewUsers()->create();
$this->actingAs($actor)
->get(route('users.print', User::factory()->create()))
->assertOk()
->assertStatus(200);
}
public function testCannotPrintUserInventoryFromAnotherCompany()
{
$this->settings->enableMultipleFullCompanySupport();
[$companyA, $companyB] = Company::factory()->count(2)->create();
$superuser = User::factory()->superuser()->create();
$actor = User::factory()->for($companyA)->viewUsers()->create();
$user = User::factory()->for($companyB)->create();
$this->actingAs(User::factory()->viewUsers()->for($companyA)->create())
->get(route('users.print', ['userId' => $user->id]))
$this->actingAs($actor)
->get(route('users.print', $user))
->assertStatus(302);
$this->actingAs(User::factory()->viewUsers()->for($companyB)->create())
->get(route('users.print', ['userId' => $user->id]))
->assertStatus(200);
$this->actingAs($superuser)
->get(route('users.print', ['userId' => $user->id]))
->assertOk()
->assertStatus(200);
}
}