3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-04-02 22:11:01 +00:00
Files
snipe-it/tests/Unit/Models/Company/GetIdForCurrentUserTest.php
2026-03-16 17:40:57 -07:00

43 lines
1.4 KiB
PHP

<?php
namespace Tests\Unit\Models\Company;
use App\Models\Company;
use App\Models\User;
use Tests\TestCase;
class GetIdForCurrentUserTest extends TestCase
{
public function test_returns_provided_value_when_full_company_support_disabled()
{
$this->settings->disableMultipleFullCompanySupport();
$this->actingAs(User::factory()->create());
$this->assertEquals(1000, Company::getIdForCurrentUser(1000));
}
public function test_returns_provided_value_for_super_users_when_full_company_support_enabled()
{
$this->settings->enableMultipleFullCompanySupport();
$this->actingAs(User::factory()->superuser()->create());
$this->assertEquals(2000, Company::getIdForCurrentUser(2000));
}
public function test_returns_non_super_users_company_id_when_full_company_support_enabled()
{
$this->settings->enableMultipleFullCompanySupport();
$this->actingAs(User::factory()->forCompany(['id' => 2000])->create());
$this->assertEquals(2000, Company::getIdForCurrentUser(1000));
}
public function test_returns_null_for_non_super_user_without_company_id_when_full_company_support_enabled()
{
$this->settings->enableMultipleFullCompanySupport();
$this->actingAs(User::factory()->create(['company_id' => null]));
$this->assertNull(Company::getIdForCurrentUser(1000));
}
}