2024-10-17 14:12:22 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Accessories\Ui;
|
|
|
|
|
|
|
|
use App\Models\Accessory;
|
|
|
|
use App\Models\Category;
|
|
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
2024-10-17 14:31:05 -07:00
|
|
|
use Tests\Support\ProvidesDataForFullMultipleCompanySupportTesting;
|
2024-10-17 14:12:22 -07:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class CreateAccessoryWithFullMultipleCompanySupportTest extends TestCase
|
|
|
|
{
|
2024-10-17 14:31:05 -07:00
|
|
|
use ProvidesDataForFullMultipleCompanySupportTesting;
|
2024-10-17 14:12:22 -07:00
|
|
|
|
2024-10-17 14:53:18 -07:00
|
|
|
#[DataProvider('dataForFullMultipleCompanySupportTesting')]
|
2024-10-17 14:12:22 -07:00
|
|
|
public function testAdheresToFullMultipleCompaniesSupportScoping($data)
|
|
|
|
{
|
|
|
|
['actor' => $actor, 'company_attempting_to_associate' => $company, 'assertions' => $assertions] = $data();
|
|
|
|
|
|
|
|
$this->settings->enableMultipleFullCompanySupport();
|
|
|
|
|
|
|
|
$this->actingAs($actor)
|
|
|
|
->post(route('accessories.store'), [
|
|
|
|
'redirect_option' => 'index',
|
|
|
|
'name' => 'My Cool Accessory',
|
|
|
|
'qty' => '1',
|
|
|
|
'category_id' => Category::factory()->create()->id,
|
|
|
|
'company_id' => $company->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$accessory = Accessory::withoutGlobalScopes()->where([
|
|
|
|
'name' => 'My Cool Accessory',
|
|
|
|
])->sole();
|
|
|
|
|
|
|
|
$assertions($accessory);
|
|
|
|
}
|
|
|
|
}
|