- 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
75 lines
2.3 KiB
PHP
75 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Company>
|
|
*/
|
|
class CompanyFactory extends Factory
|
|
{
|
|
protected $model = Company::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'name' => $this->faker->company(),
|
|
'email' => $this->faker->unique()->companyEmail(),
|
|
'address' => $this->faker->address(),
|
|
'director_name' => $this->faker->name(),
|
|
'director_nik' => $this->faker->numerify('################'),
|
|
'deed_incorporation' => $this->faker->numerify('AHU-#######.AH.##.##'),
|
|
'trade_license' => $this->faker->numerify('###/###/SIUP/####'),
|
|
'tax_id_number' => $this->faker->numerify('##.###.###.#-###.###'),
|
|
'taxable_enterprise' => $this->faker->numerify('###.###.###.###'),
|
|
'annual_tax_return' => $this->faker->numerify('SPT-####-########'),
|
|
'domicile_certificate' => $this->faker->numerify('###/###/DOMISILI/####'),
|
|
'profile' => $this->faker->numerify('PROFILE-####-########'),
|
|
'validated_at' => $this->faker->optional(0.7)->dateTimeBetween('-1 year', 'now'),
|
|
'rejection_reason' => $this->faker->optional(0.1)->sentence(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the company is validated.
|
|
*/
|
|
public function validated(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'validated_at' => $this->faker->dateTimeBetween('-6 months', 'now'),
|
|
'rejection_reason' => null,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the company is rejected.
|
|
*/
|
|
public function rejected(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'validated_at' => null,
|
|
'rejection_reason' => $this->faker->sentence(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Indicate that the company is pending validation.
|
|
*/
|
|
public function pending(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'validated_at' => null,
|
|
'rejection_reason' => null,
|
|
]);
|
|
}
|
|
}
|