now favicons
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Platform\app\Models\Company;
|
||||
use Modules\Platform\app\Models\LicenseKey;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
@@ -25,6 +27,7 @@ class UserFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'company_id' => fn (): int => $this->licensedCompany()->id,
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
@@ -33,6 +36,9 @@ class UserFactory extends Factory
|
||||
'two_factor_secret' => null,
|
||||
'two_factor_recovery_codes' => null,
|
||||
'two_factor_confirmed_at' => null,
|
||||
'is_platform_admin' => false,
|
||||
'is_company_admin' => true,
|
||||
'status' => 'active',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -57,4 +63,59 @@ class UserFactory extends Factory
|
||||
'two_factor_confirmed_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the MPBA system tenant and platform administrator flags.
|
||||
*/
|
||||
public function mpbaPlatformAdmin(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'company_id' => $this->systemCompany()->id,
|
||||
'is_platform_admin' => true,
|
||||
'is_company_admin' => true,
|
||||
'status' => 'active',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or reuse a licensed tenant company for ordinary user tests.
|
||||
*/
|
||||
private function licensedCompany(): Company
|
||||
{
|
||||
$company = Company::query()->where('slug', 'test-company')->first();
|
||||
|
||||
if (! $company) {
|
||||
$company = Company::query()->create([
|
||||
'name' => 'Test Company',
|
||||
'slug' => 'test-company',
|
||||
'status' => 'active',
|
||||
'timezone' => 'Europe/London',
|
||||
'is_system_company' => false,
|
||||
'billing_email' => 'billing@test-company.example',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $company->hasActiveLicense()) {
|
||||
LicenseKey::issueFor($company, 'Automated Test Licence', 'enterprise', 250);
|
||||
}
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or reuse the MPBA system tenant.
|
||||
*/
|
||||
private function systemCompany(): Company
|
||||
{
|
||||
return Company::query()->firstOrCreate(
|
||||
['slug' => 'mpba-limited'],
|
||||
[
|
||||
'name' => 'MPBA Limited',
|
||||
'status' => 'active',
|
||||
'timezone' => 'Europe/London',
|
||||
'is_system_company' => true,
|
||||
'billing_email' => 'mark.gregory@mpba.co.uk',
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user