- 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
122 lines
3.1 KiB
PHP
122 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\ContentType;
|
|
use App\Models\Classification;
|
|
use App\Models\ContentRecap;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ContentRecap>
|
|
*/
|
|
class ContentRecapFactory extends Factory
|
|
{
|
|
protected $model = ContentRecap::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$channels = [
|
|
'Website',
|
|
'Facebook',
|
|
'Instagram',
|
|
'Twitter',
|
|
'YouTube',
|
|
'TikTok',
|
|
'WhatsApp',
|
|
'Telegram',
|
|
'LinkedIn',
|
|
];
|
|
|
|
$socialMediaPlatforms = [
|
|
'Facebook',
|
|
'Instagram',
|
|
'Twitter',
|
|
'YouTube',
|
|
'TikTok',
|
|
'LinkedIn',
|
|
'WhatsApp',
|
|
'Telegram',
|
|
'Pinterest',
|
|
];
|
|
|
|
return [
|
|
'classification_id' => Classification::factory(),
|
|
'title' => $this->faker->sentence(4),
|
|
'link' => $this->faker->optional(0.8)->url(),
|
|
'posting_date' => $this->faker->dateTimeBetween('-6 months', 'now')->format('Y-m-d'),
|
|
'type' => $this->faker->randomElement(ContentType::cases())->value,
|
|
'channel' => $this->faker->randomElement($channels),
|
|
'social_media' => $this->faker->randomElement($socialMediaPlatforms),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the content recap is photo type.
|
|
*/
|
|
public function photo(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => ContentType::FOTO->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the content recap is video type.
|
|
*/
|
|
public function video(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => ContentType::VIDEO->value,
|
|
'channel' => $this->faker->randomElement(['YouTube', 'Instagram', 'TikTok']),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the content recap is text type.
|
|
*/
|
|
public function text(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => ContentType::TEXT->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the content recap is graphic type.
|
|
*/
|
|
public function graphic(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => ContentType::GRAPHIC->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the content recap is for Instagram.
|
|
*/
|
|
public function instagram(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'channel' => 'Instagram',
|
|
'social_media' => 'Instagram',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the content recap is for Facebook.
|
|
*/
|
|
public function facebook(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'channel' => 'Facebook',
|
|
'social_media' => 'Facebook',
|
|
]);
|
|
}
|
|
}
|