2024-09-16 16:40:10 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Checkins\Api;
|
|
|
|
|
|
|
|
use App\Models\Accessory;
|
2024-09-17 09:11:58 -07:00
|
|
|
use App\Models\Company;
|
2024-09-16 16:40:10 -07:00
|
|
|
use App\Models\User;
|
2024-09-17 09:11:58 -07:00
|
|
|
use Tests\Concerns\TestsFullMultipleCompaniesSupport;
|
2024-09-16 16:40:10 -07:00
|
|
|
use Tests\Concerns\TestsPermissionsRequirement;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-09-17 09:11:58 -07:00
|
|
|
class AccessoryCheckinTest extends TestCase implements TestsFullMultipleCompaniesSupport, TestsPermissionsRequirement
|
2024-09-16 16:40:10 -07:00
|
|
|
{
|
|
|
|
public function testRequiresPermission()
|
|
|
|
{
|
|
|
|
$accessory = Accessory::factory()->checkedOutToUser()->create();
|
|
|
|
|
|
|
|
$this->actingAsForApi(User::factory()->create())
|
|
|
|
->postJson(route('api.accessories.checkin', $accessory))
|
|
|
|
->assertForbidden();
|
|
|
|
}
|
2024-09-17 09:11:58 -07:00
|
|
|
|
|
|
|
public function testAdheresToFullMultipleCompaniesSupportScoping()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
|
|
|
|
$this->withoutExceptionHandling();
|
|
|
|
|
|
|
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
|
|
|
|
|
|
|
$userInCompanyA = User::factory()->for($companyA)->checkinAccessories()->create();
|
|
|
|
$accessoryForCompanyB = Accessory::factory()->for($companyB)->checkedOutToUser()->create();
|
|
|
|
|
|
|
|
$this->settings->enableMultipleFullCompanySupport();
|
|
|
|
|
|
|
|
$this->actingAsForApi($userInCompanyA)
|
|
|
|
->postJson(route('api.accessories.checkin', $accessoryForCompanyB))
|
|
|
|
->assertStatusMessageIs('error');
|
|
|
|
|
|
|
|
// @todo:
|
|
|
|
}
|
2024-09-16 16:40:10 -07:00
|
|
|
}
|