3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-03-31 04:44:14 +00:00
Files
snipe-it/tests/Unit/Models/Company/GetIdForCurrentUserTest.php
Marcus Moore 82e795b642 Revert "Add return types to test methods"
This reverts commit 83fb6826ee.
2024-08-06 13:30:34 -07:00

43 lines
1.3 KiB
PHP

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