mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -08:00
9adb2c24f3
commitdddbf27d78
Author: snipe <snipe@snipe.net> Date: Wed Sep 18 14:18:52 2024 +0100 Updated language strings Signed-off-by: snipe <snipe@snipe.net> commitfcefcc8184
Merge:04bb3eec8
3519a82dd
Author: snipe <snipe@snipe.net> Date: Wed Sep 18 13:44:44 2024 +0100 Merge pull request #15512 from marcusmoore/testing/fmcs Added tests for delete methods in api commit04bb3eec83
Merge:154d5d8d9
f963b9a19
Author: snipe <snipe@snipe.net> Date: Wed Sep 18 13:41:37 2024 +0100 Merge pull request #15521 from uberbrady/improve_country_selector Fix selected-index of Countries drop-down [fd-44144] commitf963b9a19f
Author: Brady Wetherington <bwetherington@grokability.com> Date: Wed Sep 18 13:24:26 2024 +0100 Fix selected-index of Countries drop-down commit154d5d8d91
Merge:6c996b775
9e5f6d656
Author: snipe <snipe@snipe.net> Date: Tue Sep 17 23:40:25 2024 +0100 Merge pull request #15491 from uberbrady/numeric_prefixes_add_multiple_assets [Fixes fd-43940] Improve multi-asset create when using numeric prefixes to asset_tags commit3519a82ddd
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 16:55:20 2024 -0700 Fix name: TestsFullMultipleCompaniesSupport commita629df07bf
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 14:49:08 2024 -0700 Implement interfaces on existing test classes commit9a13fcab23
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 14:38:38 2024 -0700 Pluralize commitf5705a1dde
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 14:34:55 2024 -0700 More unification commitf325c4afdb
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 14:32:38 2024 -0700 Unify assertion method commit1fddacd7d0
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 14:25:11 2024 -0700 Re-order test methods commit4af893df61
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 14:20:24 2024 -0700 Improve assertions commitb8b3f91ce4
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 13:55:18 2024 -0700 Formatting commit7f40f55343
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 13:52:02 2024 -0700 Add tests for delete supplier endpoint commitb06e8d442d
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 13:37:08 2024 -0700 Add tests for delete status label endpoint commitc269184c60
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 13:29:41 2024 -0700 Add tests for delete predefined kit endpoint commit53c673dee2
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 13:13:12 2024 -0700 Add tests for delete manufacturer endpoint commit50730fc4fb
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 12:37:18 2024 -0700 Add tests for delete location endpoint commit60a54cee79
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 12:33:30 2024 -0700 Add tests for delete license endpoint commit446e962a50
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 10:38:51 2024 -0700 Add tests for delete group endpoint commit79a4bb7316
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 10:35:44 2024 -0700 Add tests for delete depreciation endpoint commit2f76c1bc5b
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 10:33:21 2024 -0700 Add assertion commit38b9f4a438
Author: Marcus Moore <contact@marcusmoore.io> Date: Mon Sep 16 10:29:20 2024 -0700 Add tests for delete departments endpoint commit3105f53aff
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 16:54:29 2024 -0700 Add tests for delete custom fieldsets endpoint commit2047cfed09
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 16:20:32 2024 -0700 Add tests for delete custom fields endpoint commite3268d32df
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 16:00:02 2024 -0700 Add tests for delete consumable endpoint commit6df8b0ac0e
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 15:52:07 2024 -0700 Add tests for delete component endpoint commit910f13c1f7
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 15:38:30 2024 -0700 Add tests for delete companies endpoint commit8ce2512f55
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:54:44 2024 -0700 Add tests for delete category endpoint commit0ec415d4d0
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:46:22 2024 -0700 Clean up commit2044570e95
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:39:36 2024 -0700 Add tests for delete asset model endpoint commitb336c6273d
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:32:42 2024 -0700 Pluralize test classes commit5299b3e9f0
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:29:44 2024 -0700 Remove code handled by CompanyableChildTrait commit872b76b45f
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:29:10 2024 -0700 Add tests for delete asset maintenance endpoint commit275cf4630e
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:16:37 2024 -0700 Add tests for delete asset endpoint commit5c2660bd34
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 13:02:32 2024 -0700 Introduce interface commitc7ae9d9dfa
Author: Marcus Moore <contact@marcusmoore.io> Date: Thu Sep 12 12:58:47 2024 -0700 Add tests for delete accessory endpoint commit9e5f6d656a
Author: Brady Wetherington <bwetherington@grokability.com> Date: Wed Sep 11 15:45:01 2024 +0100 Improve multi-asset create when using numeric prefixes to asset_tags Signed-off-by: snipe <snipe@snipe.net>
388 lines
9.7 KiB
PHP
388 lines
9.7 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use \Auth;
|
|
|
|
class UserFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition()
|
|
{
|
|
return [
|
|
'activated' => 1,
|
|
'address' => $this->faker->address(),
|
|
'city' => $this->faker->city(),
|
|
'company_id' => Company::factory(),
|
|
'country' => $this->faker->country(),
|
|
'email' => $this->faker->safeEmail(),
|
|
'employee_num' => $this->faker->numberBetween(3500, 35050),
|
|
'first_name' => $this->faker->firstName(),
|
|
'jobtitle' => $this->faker->jobTitle(),
|
|
'last_name' => $this->faker->lastName(),
|
|
'locale' => 'en-US',
|
|
'notes' => 'Created by DB seeder',
|
|
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
|
'permissions' => '{}',
|
|
'phone' => $this->faker->phoneNumber(),
|
|
'state' => $this->faker->stateAbbr(),
|
|
'username' => $this->faker->unique()->username(),
|
|
'zip' => $this->faker->postcode(),
|
|
];
|
|
}
|
|
|
|
public function deletedUser()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'deleted_at' => $this->faker->dateTime(),
|
|
];
|
|
});
|
|
}
|
|
|
|
|
|
public function firstAdmin()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'first_name' => 'Admin',
|
|
'last_name' => 'User',
|
|
'username' => 'admin',
|
|
'avatar' => '1.jpg',
|
|
'permissions' => '{"superuser":"1"}',
|
|
];
|
|
});
|
|
}
|
|
|
|
public function snipeAdmin()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'first_name' => 'Snipe E.',
|
|
'last_name' => 'Head',
|
|
'username' => 'snipe',
|
|
'avatar' => '2.jpg',
|
|
'email' => 'snipe@snipe.net',
|
|
'permissions' => '{"superuser":"1"}',
|
|
];
|
|
});
|
|
}
|
|
|
|
public function testAdmin()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'first_name' => 'Alison',
|
|
'last_name' => 'Gianotto',
|
|
'username' => 'agianotto@grokability.com',
|
|
'avatar' => '2.jpg',
|
|
'email' => 'agianotto@grokability.com',
|
|
'permissions' => '{"superuser":"1"}',
|
|
];
|
|
});
|
|
}
|
|
|
|
public function superuser()
|
|
{
|
|
return $this->appendPermission(['superuser' => '1']);
|
|
}
|
|
|
|
public function admin()
|
|
{
|
|
return $this->state(function () {
|
|
return [
|
|
'permissions' => '{"admin":"1"}',
|
|
'manager_id' => function () {
|
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
|
},
|
|
];
|
|
});
|
|
}
|
|
|
|
public function viewAssets()
|
|
{
|
|
return $this->appendPermission(['assets.view' => '1']);
|
|
}
|
|
|
|
public function createAssets()
|
|
{
|
|
return $this->appendPermission(['assets.create' => '1']);
|
|
}
|
|
|
|
public function editAssets()
|
|
{
|
|
return $this->appendPermission(['assets.edit' => '1']);
|
|
}
|
|
|
|
public function deleteAssets()
|
|
{
|
|
return $this->appendPermission(['assets.delete' => '1']);
|
|
}
|
|
|
|
public function checkinAssets()
|
|
{
|
|
return $this->appendPermission(['assets.checkin' => '1']);
|
|
}
|
|
|
|
public function checkoutAssets()
|
|
{
|
|
return $this->appendPermission(['assets.checkout' => '1']);
|
|
}
|
|
|
|
public function viewRequestableAssets()
|
|
{
|
|
return $this->appendPermission(['assets.view.requestable' => '1']);
|
|
}
|
|
|
|
public function deleteAssetModels()
|
|
{
|
|
return $this->appendPermission(['models.delete' => '1']);
|
|
}
|
|
|
|
public function viewAccessories()
|
|
{
|
|
return $this->appendPermission(['accessories.view' => '1']);
|
|
}
|
|
|
|
public function createAccessories()
|
|
{
|
|
return $this->appendPermission(['accessories.create' => '1']);
|
|
}
|
|
|
|
public function editAccessories()
|
|
{
|
|
return $this->appendPermission(['accessories.edit' => '1']);
|
|
}
|
|
|
|
public function deleteAccessories()
|
|
{
|
|
return $this->appendPermission(['accessories.delete' => '1']);
|
|
}
|
|
|
|
public function checkinAccessories()
|
|
{
|
|
return $this->appendPermission(['accessories.checkin' => '1']);
|
|
}
|
|
|
|
public function checkoutAccessories()
|
|
{
|
|
return $this->appendPermission(['accessories.checkout' => '1']);
|
|
}
|
|
|
|
public function viewConsumables()
|
|
{
|
|
return $this->appendPermission(['consumables.view' => '1']);
|
|
}
|
|
|
|
public function createConsumables()
|
|
{
|
|
return $this->appendPermission(['consumables.create' => '1']);
|
|
}
|
|
|
|
public function editConsumables()
|
|
{
|
|
return $this->appendPermission(['consumables.edit' => '1']);
|
|
}
|
|
|
|
public function deleteConsumables()
|
|
{
|
|
return $this->appendPermission(['consumables.delete' => '1']);
|
|
}
|
|
|
|
public function checkinConsumables()
|
|
{
|
|
return $this->appendPermission(['consumables.checkin' => '1']);
|
|
}
|
|
|
|
public function checkoutConsumables()
|
|
{
|
|
return $this->appendPermission(['consumables.checkout' => '1']);
|
|
}
|
|
|
|
public function deleteDepartments()
|
|
{
|
|
return $this->appendPermission(['departments.delete' => '1']);
|
|
}
|
|
|
|
public function viewDepartments()
|
|
{
|
|
return $this->appendPermission(['departments.view' => '1']);
|
|
}
|
|
|
|
public function viewLicenses()
|
|
{
|
|
return $this->appendPermission(['licenses.view' => '1']);
|
|
}
|
|
|
|
public function createLicenses()
|
|
{
|
|
return $this->appendPermission(['licenses.create' => '1']);
|
|
}
|
|
|
|
public function editLicenses()
|
|
{
|
|
return $this->appendPermission(['licenses.edit' => '1']);
|
|
}
|
|
|
|
public function deleteLicenses()
|
|
{
|
|
return $this->appendPermission(['licenses.delete' => '1']);
|
|
}
|
|
|
|
public function checkoutLicenses()
|
|
{
|
|
return $this->appendPermission(['licenses.checkout' => '1']);
|
|
}
|
|
|
|
public function viewKeysLicenses()
|
|
{
|
|
return $this->appendPermission(['licenses.keys' => '1']);
|
|
}
|
|
|
|
public function viewComponents()
|
|
{
|
|
return $this->appendPermission(['components.view' => '1']);
|
|
}
|
|
|
|
public function createComponents()
|
|
{
|
|
return $this->appendPermission(['components.create' => '1']);
|
|
}
|
|
|
|
public function editComponents()
|
|
{
|
|
return $this->appendPermission(['components.edit' => '1']);
|
|
}
|
|
|
|
public function deleteComponents()
|
|
{
|
|
return $this->appendPermission(['components.delete' => '1']);
|
|
}
|
|
|
|
public function checkinComponents()
|
|
{
|
|
return $this->appendPermission(['components.checkin' => '1']);
|
|
}
|
|
|
|
public function checkoutComponents()
|
|
{
|
|
return $this->appendPermission(['components.checkout' => '1']);
|
|
}
|
|
|
|
public function createCompanies()
|
|
{
|
|
return $this->appendPermission(['companies.create' => '1']);
|
|
}
|
|
|
|
public function deleteCompanies()
|
|
{
|
|
return $this->appendPermission(['companies.delete' => '1']);
|
|
}
|
|
|
|
public function viewUsers()
|
|
{
|
|
return $this->appendPermission(['users.view' => '1']);
|
|
}
|
|
|
|
public function createUsers()
|
|
{
|
|
return $this->appendPermission(['users.create' => '1']);
|
|
}
|
|
|
|
public function editUsers()
|
|
{
|
|
return $this->appendPermission(['users.edit' => '1']);
|
|
}
|
|
|
|
public function deleteUsers()
|
|
{
|
|
return $this->appendPermission(['users.delete' => '1']);
|
|
}
|
|
|
|
public function deleteCategories()
|
|
{
|
|
return $this->appendPermission(['categories.delete' => '1']);
|
|
}
|
|
|
|
public function deleteLocations()
|
|
{
|
|
return $this->appendPermission(['locations.delete' => '1']);
|
|
}
|
|
|
|
public function canEditOwnLocation()
|
|
{
|
|
return $this->appendPermission(['self.edit_location' => '1']);
|
|
}
|
|
|
|
public function canViewReports()
|
|
{
|
|
return $this->appendPermission(['reports.view' => '1']);
|
|
}
|
|
|
|
public function canImport()
|
|
{
|
|
return $this->appendPermission(['import' => '1']);
|
|
}
|
|
|
|
public function deleteCustomFields()
|
|
{
|
|
return $this->appendPermission(['customfields.delete' => '1']);
|
|
}
|
|
|
|
public function deleteCustomFieldsets()
|
|
{
|
|
return $this->appendPermission(['customfields.delete' => '1']);
|
|
}
|
|
|
|
public function deleteDepreciations()
|
|
{
|
|
return $this->appendPermission(['depreciations.delete' => '1']);
|
|
}
|
|
|
|
public function deleteManufacturers()
|
|
{
|
|
return $this->appendPermission(['manufacturers.delete' => '1']);
|
|
}
|
|
|
|
public function deletePredefinedKits()
|
|
{
|
|
return $this->appendPermission(['kits.delete' => '1']);
|
|
}
|
|
|
|
public function deleteStatusLabels()
|
|
{
|
|
return $this->appendPermission(['statuslabels.delete' => '1']);
|
|
}
|
|
|
|
public function deleteSuppliers()
|
|
{
|
|
return $this->appendPermission(['suppliers.delete' => '1']);
|
|
}
|
|
|
|
private function appendPermission(array $permission)
|
|
{
|
|
return $this->state(function ($currentState) use ($permission) {
|
|
return [
|
|
'permissions' => json_encode(
|
|
array_merge(
|
|
json_decode($currentState['permissions'], true),
|
|
$permission
|
|
)
|
|
),
|
|
];
|
|
});
|
|
}
|
|
|
|
public function deleted(): self
|
|
{
|
|
return $this->state(['deleted_at' => $this->faker->dateTime()]);
|
|
}
|
|
}
|