- Add HasFactory trait to all model classes for factory support - Create factory classes for all models (Classification, Company, ContentRecap, Department, IssueManagement, Journalist, Location, MediaMonitoring, MediaMonitoringTheme, PartnerMedia, SubClassification, SubLocation, Theme, User) - Add unit tests for all models with relationship and attribute validation - Add unit tests for all enums (Channel, ContentType, IsActive, IssueSentiment, MediaClassification, MediaType, SocialMedia) - Add feature tests for factory integration and basic application functionality - Add tests for Filament actions, columns, and media library utilities - Add tests for model policies (Classification, Theme) and traits (WithComment, WithValue) - Update phpunit.xml configuration for test environment - Add test documentation and working tests reference guide - Add ContentType enum casting to ContentRecap model - Add MediaMonitoringTheme relationships and factory support - Establish comprehensive testing infrastructure for improved code quality and reliability
110 lines
3.0 KiB
PHP
110 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\IssueSentiment;
|
|
use App\Models\Classification;
|
|
use App\Models\IssueManagement;
|
|
use App\Models\Location;
|
|
use App\Models\MediaMonitoring;
|
|
use App\Models\SubClassification;
|
|
use App\Models\SubLocation;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\IssueManagement>
|
|
*/
|
|
class IssueManagementFactory extends Factory
|
|
{
|
|
protected $model = IssueManagement::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'location_id' => Location::factory(),
|
|
'sub_location_id' => SubLocation::factory(),
|
|
'classification_id' => Classification::factory(),
|
|
'sub_classification_id' => SubClassification::factory(),
|
|
'media_monitoring_id' => MediaMonitoring::factory(),
|
|
'issue' => $this->faker->randomElement(IssueSentiment::cases())->value,
|
|
'response' => $this->faker->randomElement(IssueSentiment::cases())->value,
|
|
'description' => $this->faker->paragraphs(2, true),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the issue is positive.
|
|
*/
|
|
public function positive(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'issue' => IssueSentiment::POSITIVE->value,
|
|
'response' => IssueSentiment::POSITIVE->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the issue is negative.
|
|
*/
|
|
public function negative(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'issue' => IssueSentiment::NEGATIVE->value,
|
|
'response' => $this->faker->randomElement([
|
|
IssueSentiment::POSITIVE->value,
|
|
IssueSentiment::NEUTRAL->value,
|
|
]),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the issue is neutral.
|
|
*/
|
|
public function neutral(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'issue' => IssueSentiment::NEUTRAL->value,
|
|
'response' => IssueSentiment::NEUTRAL->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the issue is crisis.
|
|
*/
|
|
public function crisis(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'issue' => IssueSentiment::CRISIS->value,
|
|
'response' => $this->faker->randomElement([
|
|
IssueSentiment::POSITIVE->value,
|
|
IssueSentiment::NEUTRAL->value,
|
|
]),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the issue has no sub location.
|
|
*/
|
|
public function withoutSubLocation(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'sub_location_id' => null,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the issue has no sub classification.
|
|
*/
|
|
public function withoutSubClassification(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'sub_classification_id' => null,
|
|
]);
|
|
}
|
|
}
|