- Add email normalization to TeamInvitation model using setEmailAttribute() - Add HasFactory trait to Team model for testing support - Create TeamFactory for testing - Add tests to verify email normalization works correctly - Fixes issue where mixed case emails in invitations would cause lookup failures - Resolves #6291 The bug occurred because: 1. User model normalizes emails to lowercase 2. TeamInvitation model did not normalize emails 3. When invitation was created with mixed case, it was stored as-is 4. User lookup failed due to case mismatch during invitation acceptance 5. This caused users to not be able to see teams they were invited to This fix ensures both models normalize emails consistently.
40 lines
925 B
PHP
40 lines
925 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Team;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Team>
|
|
*/
|
|
class TeamFactory extends Factory
|
|
{
|
|
protected $model = Team::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => $this->faker->company() . ' Team',
|
|
'description' => $this->faker->sentence(),
|
|
'personal_team' => false,
|
|
'show_boarding' => false,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the team is a personal team.
|
|
*/
|
|
public function personal(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'personal_team' => true,
|
|
'name' => $this->faker->firstName() . "'s Team",
|
|
]);
|
|
}
|
|
}
|