add tests

This commit is contained in:
Bob Molitor
2025-10-20 22:14:15 +02:00
parent aa23eec392
commit 0bbb4571bd
5 changed files with 300 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace Database\Factories;
use App\Models\Company;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<\App\Models\Company>
*/
class CompanyFactory extends Factory
{
protected $model = Company::class;
public function definition(): array
{
return [
'name' => $this->faker->unique()->company() . ' ' . Str::upper(Str::random(3)),
'legal_name' => $this->faker->company() . ' AG',
'ticker' => Str::upper($this->faker->lexify('???')),
'sector' => $this->faker->randomElement(['Finance', 'Technology', 'Energy']),
'country' => $this->faker->randomElement(['DE', 'AT', 'CH']),
'headquarters' => $this->faker->city(),
'kyc_risk_level' => $this->faker->randomElement(['low', 'medium', 'high']),
'summary' => $this->faker->sentence(8),
];
}
public function highRisk(): static
{
return $this->state(fn () => ['kyc_risk_level' => 'high']);
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace Database\Factories;
use App\Models\Company;
use App\Models\Transaction;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<\App\Models\Transaction>
*/
class TransactionFactory extends Factory
{
protected $model = Transaction::class;
public function definition(): array
{
return [
'company_id' => Company::factory(),
'reference' => Str::upper($this->faker->unique()->bothify('TRX########')),
'amount' => $this->faker->randomFloat(2, 1000, 500000),
'currency' => 'EUR',
'counterparty' => $this->faker->company(),
'counterparty_country' => $this->faker->countryCode(),
'channel' => $this->faker->randomElement(['SWIFT', 'SEPA', 'ACH']),
'executed_at' => $this->faker->dateTimeBetween('-7 days', 'now'),
'risk_score' => $this->faker->numberBetween(10, 99),
'status' => $this->faker->randomElement([
Transaction::STATUS_TRUE_POSITIVE,
Transaction::STATUS_FALSE_POSITIVE,
Transaction::STATUS_CLEARED,
]),
'requires_review' => $this->faker->boolean(70),
'flagged_by' => $this->faker->randomElement(['Rule Engine', 'Sanctions Monitor', 'Analyst']),
'flagged_reason' => $this->faker->sentence(6),
'signals' => [$this->faker->word()],
];
}
public function requiresReview(bool $value = true): static
{
return $this->state(fn () => ['requires_review' => $value]);
}
public function status(string $status): static
{
return $this->state(fn () => ['status' => $status]);
}
}