mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 11:43:47 -08:00
implement FMCS test for accessory index
This commit is contained in:
parent
e835637ef0
commit
8eb1c487bc
|
@ -2,11 +2,14 @@
|
|||
|
||||
namespace Tests\Feature\Accessories\Api;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use Tests\Concerns\TestsMultipleFullCompanySupport;
|
||||
use Tests\Concerns\TestsPermissionsRequirement;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IndexAccessoryTest extends TestCase implements TestsPermissionsRequirement
|
||||
class IndexAccessoryTest extends TestCase implements TestsMultipleFullCompanySupport, TestsPermissionsRequirement
|
||||
{
|
||||
public function testRequiresPermission()
|
||||
{
|
||||
|
@ -14,4 +17,40 @@ class IndexAccessoryTest extends TestCase implements TestsPermissionsRequirement
|
|||
->getJson(route('api.accessories.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testAdheresToMultipleFullCompanySupportScoping()
|
||||
{
|
||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||
|
||||
$accessoryA = Accessory::factory()->for($companyA)->create(['name' => 'Accessory A']);
|
||||
$accessoryB = Accessory::factory()->for($companyB)->create(['name' => 'Accessory B']);
|
||||
$accessoryC = Accessory::factory()->for($companyB)->create(['name' => 'Accessory C']);
|
||||
|
||||
$superUser = $companyA->users()->save(User::factory()->superuser()->make());
|
||||
$userInCompanyA = $companyA->users()->save(User::factory()->viewAccessories()->make());
|
||||
$userInCompanyB = $companyB->users()->save(User::factory()->viewAccessories()->make());
|
||||
|
||||
$this->settings->enableMultipleFullCompanySupport();
|
||||
|
||||
$this->actingAsForApi($userInCompanyA)
|
||||
->getJson(route('api.accessories.index'))
|
||||
->assertOk()
|
||||
->assertResponseContainsInRows($accessoryA)
|
||||
->assertResponseDoesNotContainInRows($accessoryB)
|
||||
->assertResponseDoesNotContainInRows($accessoryC);
|
||||
|
||||
$this->actingAsForApi($userInCompanyB)
|
||||
->getJson(route('api.accessories.index'))
|
||||
->assertOk()
|
||||
->assertResponseDoesNotContainInRows($accessoryA)
|
||||
->assertResponseContainsInRows($accessoryB)
|
||||
->assertResponseContainsInRows($accessoryC);
|
||||
|
||||
$this->actingAsForApi($superUser)
|
||||
->getJson(route('api.accessories.index'))
|
||||
->assertOk()
|
||||
->assertResponseContainsInRows($accessoryA)
|
||||
->assertResponseContainsInRows($accessoryB)
|
||||
->assertResponseContainsInRows($accessoryC);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue