diff --git a/tests/Feature/Importing/Api/ImportAccessoriesTest.php b/tests/Feature/Importing/Api/ImportAccessoriesTest.php index 27a80c0dd0..b4285775fc 100644 --- a/tests/Feature/Importing/Api/ImportAccessoriesTest.php +++ b/tests/Feature/Importing/Api/ImportAccessoriesTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature\Importing\Api; use App\Models\Accessory; use App\Models\Actionlog; use App\Models\Company; +use App\Models\User; use Database\Factories\AccessoryFactory; use Database\Factories\CompanyFactory; use Illuminate\Support\Str; @@ -15,9 +16,10 @@ use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Arr; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Attributes\DataProvider; +use Tests\Concerns\TestsPermissionsRequirement; use Tests\Support\Importing\AccessoriesImportFileBuilder as ImportFileBuilder; -class ImportAccessoriesTest extends ImportDataTestCase +class ImportAccessoriesTest extends ImportDataTestCase implements TestsPermissionsRequirement { use WithFaker; @@ -31,14 +33,9 @@ class ImportAccessoriesTest extends ImportDataTestCase } #[Test] - #[DataProvider('permissionsTestData')] - public function onlyUserWithPermissionCanImportAccessories(array|string $permissions): void + public function testRequiresPermission() { - $permissions = collect((array) $permissions) - ->map(fn (string $permission) => [$permission => '1']) - ->toJson(); - - $this->actingAsForApi(UserFactory::new()->create(['permissions' => $permissions])); + $this->actingAsForApi(User::factory()->create()); $this->importFileResponse(['import' => 44])->assertForbidden(); } diff --git a/tests/Feature/Importing/Api/ImportAssetsTest.php b/tests/Feature/Importing/Api/ImportAssetsTest.php index d4b6ac52e7..70e61b41dc 100644 --- a/tests/Feature/Importing/Api/ImportAssetsTest.php +++ b/tests/Feature/Importing/Api/ImportAssetsTest.php @@ -19,9 +19,10 @@ use Illuminate\Support\Arr; use Illuminate\Support\Facades\Notification; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Attributes\DataProvider; +use Tests\Concerns\TestsPermissionsRequirement; use Tests\Support\Importing\AssetsImportFileBuilder as ImportFileBuilder; -class ImportAssetsTest extends ImportDataTestCase +class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsRequirement { use WithFaker; @@ -35,14 +36,9 @@ class ImportAssetsTest extends ImportDataTestCase } #[Test] - #[DataProvider('permissionsTestData')] - public function onlyUserWithPermissionCanImportAssets(array|string $permissions): void + public function testRequiresPermission() { - $permissions = collect((array) $permissions) - ->map(fn (string $permission) => [$permission => '1']) - ->toJson(); - - $this->actingAsForApi(UserFactory::new()->create(['permissions' => $permissions])); + $this->actingAsForApi(User::factory()->create()); $this->importFileResponse(['import' => 44])->assertForbidden(); } diff --git a/tests/Feature/Importing/Api/ImportComponentsTest.php b/tests/Feature/Importing/Api/ImportComponentsTest.php index 1a68fbf1c2..c8a1209cf3 100644 --- a/tests/Feature/Importing/Api/ImportComponentsTest.php +++ b/tests/Feature/Importing/Api/ImportComponentsTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature\Importing\Api; use App\Models\Actionlog as ActionLog; use App\Models\Component; +use App\Models\User; use Database\Factories\ComponentFactory; use Illuminate\Support\Str; use Database\Factories\UserFactory; @@ -13,9 +14,10 @@ use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Facades\Notification; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Attributes\DataProvider; +use Tests\Concerns\TestsPermissionsRequirement; use Tests\Support\Importing\ComponentsImportFileBuilder as ImportFileBuilder; -class ImportComponentsTest extends ImportDataTestCase +class ImportComponentsTest extends ImportDataTestCase implements TestsPermissionsRequirement { use WithFaker; @@ -29,14 +31,9 @@ class ImportComponentsTest extends ImportDataTestCase } #[Test] - #[DataProvider('permissionsTestData')] - public function onlyUserWithPermissionCanImportComponents(array|string $permissions): void + public function testRequiresPermission() { - $permissions = collect((array) $permissions) - ->map(fn (string $permission) => [$permission => '1']) - ->toJson(); - - $this->actingAsForApi(UserFactory::new()->create(['permissions' => $permissions])); + $this->actingAsForApi(User::factory()->create()); $this->importFileResponse(['import' => 44])->assertForbidden(); } diff --git a/tests/Feature/Importing/Api/ImportConsumablesTest.php b/tests/Feature/Importing/Api/ImportConsumablesTest.php index 3962dea5d4..7647946dd9 100644 --- a/tests/Feature/Importing/Api/ImportConsumablesTest.php +++ b/tests/Feature/Importing/Api/ImportConsumablesTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature\Importing\Api; use App\Models\Actionlog as ActivityLog; use App\Models\Consumable; +use App\Models\User; use Database\Factories\ConsumableFactory; use Illuminate\Support\Str; use Database\Factories\UserFactory; @@ -13,9 +14,10 @@ use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Facades\Notification; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Attributes\DataProvider; +use Tests\Concerns\TestsPermissionsRequirement; use Tests\Support\Importing\ConsumablesImportFileBuilder as ImportFileBuilder; -class ImportConsumablesTest extends ImportDataTestCase +class ImportConsumablesTest extends ImportDataTestCase implements TestsPermissionsRequirement { use WithFaker; @@ -29,14 +31,9 @@ class ImportConsumablesTest extends ImportDataTestCase } #[Test] - #[DataProvider('permissionsTestData')] - public function onlyUserWithPermissionCanImportConsumables(array|string $permissions): void + public function testRequiresPermission() { - $permissions = collect((array) $permissions) - ->map(fn (string $permission) => [$permission => '1']) - ->toJson(); - - $this->actingAsForApi(UserFactory::new()->create(['permissions' => $permissions])); + $this->actingAsForApi(User::factory()->create()); $this->importFileResponse(['import' => 44])->assertForbidden(); } diff --git a/tests/Feature/Importing/Api/ImportLicenseTest.php b/tests/Feature/Importing/Api/ImportLicenseTest.php index 11865236f3..0d9e3e2a5d 100644 --- a/tests/Feature/Importing/Api/ImportLicenseTest.php +++ b/tests/Feature/Importing/Api/ImportLicenseTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature\Importing\Api; use App\Models\Actionlog as ActivityLog; use App\Models\License; +use App\Models\User; use Illuminate\Support\Str; use Database\Factories\UserFactory; use Database\Factories\ImportFactory; @@ -12,9 +13,10 @@ use PHPUnit\Framework\Attributes\Test; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Attributes\DataProvider; +use Tests\Concerns\TestsPermissionsRequirement; use Tests\Support\Importing\LicensesImportFileBuilder as ImportFileBuilder; -class ImportLicenseTest extends ImportDataTestCase +class ImportLicenseTest extends ImportDataTestCase implements TestsPermissionsRequirement { use WithFaker; @@ -28,14 +30,9 @@ class ImportLicenseTest extends ImportDataTestCase } #[Test] - #[DataProvider('permissionsTestData')] - public function onlyUserWithPermissionCanImportLicenses(array|string $permissions): void + public function testRequiresPermission() { - $permissions = collect((array) $permissions) - ->map(fn (string $permission) => [$permission => '1']) - ->toJson(); - - $this->actingAsForApi(UserFactory::new()->create(['permissions' => $permissions])); + $this->actingAsForApi(User::factory()->create()); $this->importFileResponse(['import' => 44])->assertForbidden(); } diff --git a/tests/Feature/Importing/Api/ImportUsersTest.php b/tests/Feature/Importing/Api/ImportUsersTest.php index 6ac0070a19..f506c0ac27 100644 --- a/tests/Feature/Importing/Api/ImportUsersTest.php +++ b/tests/Feature/Importing/Api/ImportUsersTest.php @@ -15,9 +15,10 @@ use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Notification; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Attributes\DataProvider; +use Tests\Concerns\TestsPermissionsRequirement; use Tests\Support\Importing\UsersImportFileBuilder as ImportFileBuilder; -class ImportUsersTest extends ImportDataTestCase +class ImportUsersTest extends ImportDataTestCase implements TestsPermissionsRequirement { use WithFaker; @@ -31,14 +32,9 @@ class ImportUsersTest extends ImportDataTestCase } #[Test] - #[DataProvider('permissionsTestData')] - public function onlyUserWithPermissionCanImportUsers(array|string $permissions): void + public function testRequiresPermission() { - $permissions = collect((array) $permissions) - ->map(fn (string $permission) => [$permission => '1']) - ->toJson(); - - $this->actingAsForApi(UserFactory::new()->create(['permissions' => $permissions])); + $this->actingAsForApi(User::factory()->create()); $this->importFileResponse(['import' => 44])->assertForbidden(); }