- 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
107 lines
3.0 KiB
PHP
107 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\MediaMonitoring;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MediaMonitoring>
|
|
*/
|
|
class MediaMonitoringFactory extends Factory
|
|
{
|
|
protected $model = MediaMonitoring::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$mediaNames = [
|
|
'Kompas.com',
|
|
'Detik.com',
|
|
'Tribun News',
|
|
'Liputan6',
|
|
'CNN Indonesia',
|
|
'ANTARA News',
|
|
'Tempo.co',
|
|
'Okezone',
|
|
'Suara.com',
|
|
'Bisnis.com',
|
|
];
|
|
|
|
$channels = [
|
|
'Website',
|
|
'Facebook',
|
|
'Instagram',
|
|
'Twitter',
|
|
'YouTube',
|
|
'TikTok',
|
|
'WhatsApp',
|
|
'Telegram',
|
|
'LinkedIn',
|
|
];
|
|
|
|
return [
|
|
'code' => $this->faker->unique()->regexify('[A-Z]{2}[0-9]{8}'),
|
|
'media_name' => $this->faker->randomElement($mediaNames),
|
|
'title' => $this->faker->sentence(6),
|
|
'channel' => $this->faker->randomElement($channels),
|
|
'writter' => $this->faker->name(),
|
|
'link' => $this->faker->optional(0.8)->url(),
|
|
'news_page' => $this->faker->optional(0.3)->numberBetween(1, 20),
|
|
'quote' => $this->faker->optional(0.4)->paragraph(),
|
|
'content' => $this->faker->paragraphs(3, true),
|
|
'influencer' => $this->faker->optional(0.2)->name(),
|
|
'keyword' => implode(', ', $this->faker->words(3)),
|
|
'release_date' => $this->faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the media monitoring is for online media.
|
|
*/
|
|
public function online(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'channel' => $this->faker->randomElement(['Website', 'Facebook', 'Instagram', 'Twitter']),
|
|
'link' => $this->faker->url(),
|
|
'news_page' => null,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the media monitoring is for print media.
|
|
*/
|
|
public function print(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'channel' => 'Print',
|
|
'link' => null,
|
|
'news_page' => $this->faker->numberBetween(1, 20),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the media monitoring has influencer mention.
|
|
*/
|
|
public function withInfluencer(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'influencer' => $this->faker->name(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the media monitoring has quote.
|
|
*/
|
|
public function withQuote(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'quote' => $this->faker->paragraph(),
|
|
]);
|
|
}
|
|
}
|