- 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
121 lines
3.3 KiB
PHP
121 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\MediaClassification;
|
|
use App\Enums\MediaType;
|
|
use App\Models\Company;
|
|
use App\Models\PartnerMedia;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PartnerMedia>
|
|
*/
|
|
class PartnerMediaFactory extends Factory
|
|
{
|
|
protected $model = PartnerMedia::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',
|
|
'Media Indonesia',
|
|
'Republika',
|
|
'Koran Sindo',
|
|
'Pikiran Rakyat',
|
|
];
|
|
|
|
return [
|
|
'company_id' => Company::factory(),
|
|
'name' => $this->faker->randomElement($mediaNames),
|
|
'address' => $this->faker->address(),
|
|
'link' => $this->faker->optional(0.8)->url(),
|
|
'type' => $this->faker->randomElement(MediaType::cases())->value,
|
|
'classification' => $this->faker->randomElement(MediaClassification::cases())->value,
|
|
'journalism_organization' => $this->faker->optional(0.6)->randomElement([
|
|
'Persatuan Wartawan Indonesia (PWI)',
|
|
'Aliansi Jurnalis Independen (AJI)',
|
|
'Ikatan Jurnalis Televisi Indonesia (IJTI)',
|
|
'Persatuan Jurnalis Online Indonesia (PJOI)',
|
|
]),
|
|
'press_council_certificate' => $this->faker->optional(0.7)->numerify('DEP-###/####/KP'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the partner media is online type.
|
|
*/
|
|
public function online(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => MediaType::ONLINE->value,
|
|
'link' => $this->faker->url(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the partner media is print type.
|
|
*/
|
|
public function print(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => MediaType::PRINT->value,
|
|
'link' => null,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the partner media is television type.
|
|
*/
|
|
public function television(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => MediaType::TELEVISION->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the partner media is radio type.
|
|
*/
|
|
public function radio(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => MediaType::RADIO->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the partner media is national classification.
|
|
*/
|
|
public function national(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'classification' => MediaClassification::NATIONAL->value,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the partner media is local classification.
|
|
*/
|
|
public function local(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'classification' => MediaClassification::LOCAL->value,
|
|
]);
|
|
}
|
|
}
|