Skip to content

Commit 979e450

Browse files
committed
Have getIdForCurrentUser method return null if FMCS enabled, user is not super admin, and does not have company
1 parent 99dd51a commit 979e450

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/Models/Company.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function getIdForCurrentUser($unescaped_input)
116116
if ($current_user->company_id != null) {
117117
return $current_user->company_id;
118118
} else {
119-
return static::getIdFromInput($unescaped_input);
119+
return null;
120120
}
121121
}
122122
}

tests/Unit/Models/Company/GetIdForCurrentUserTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
use App\Models\Company;
66
use App\Models\User;
7+
use PHPUnit\Framework\Attributes\Group;
78
use Tests\TestCase;
89

10+
#[Group('focus')]
911
class GetIdForCurrentUserTest extends TestCase
1012
{
1113
public function testReturnsProvidedValueWhenFullCompanySupportDisabled()
@@ -32,11 +34,11 @@ public function testReturnsNonSuperUsersCompanyIdWhenFullCompanySupportEnabled()
3234
$this->assertEquals(2000, Company::getIdForCurrentUser(1000));
3335
}
3436

35-
public function testReturnsProvidedValueForNonSuperUserWithoutCompanyIdWhenFullCompanySupportEnabled()
37+
public function testReturnsNullForNonSuperUserWithoutCompanyIdWhenFullCompanySupportEnabled()
3638
{
3739
$this->settings->enableMultipleFullCompanySupport();
3840

3941
$this->actingAs(User::factory()->create(['company_id' => null]));
40-
$this->assertEquals(1000, Company::getIdForCurrentUser(1000));
42+
$this->assertNull(Company::getIdForCurrentUser(1000));
4143
}
4244
}

0 commit comments

Comments
 (0)