mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-28 07:43:18 +00:00
🛠️ Add Eloquent factories for ProjectProposal and Election models, integrate HasFactory trait, and update tests with NostrAuth for authentication validation.
This commit is contained in:
@@ -23,4 +23,30 @@ class EinundzwanzigPlebFactory extends Factory
|
||||
'association_status' => \App\Enums\AssociationStatus::DEFAULT,
|
||||
];
|
||||
}
|
||||
|
||||
public function active(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'association_status' => \App\Enums\AssociationStatus::ACTIVE,
|
||||
]);
|
||||
}
|
||||
|
||||
public function boardMember(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'association_status' => \App\Enums\AssociationStatus::HONORARY,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withPaidCurrentYear(): static
|
||||
{
|
||||
return $this->afterCreating(function (\App\Models\EinundzwanzigPleb $pleb) {
|
||||
$pleb->paymentEvents()->create([
|
||||
'year' => date('Y'),
|
||||
'amount' => 21000,
|
||||
'paid' => true,
|
||||
'event_id' => 'test_event_'.fake()->sha256(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
25
database/factories/ElectionFactory.php
Normal file
25
database/factories/ElectionFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Election>
|
||||
*/
|
||||
class ElectionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'year' => $this->faker->year(),
|
||||
'candidates' => [],
|
||||
'end_time' => $this->faker->dateTimeBetween('now', '+1 year'),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
database/factories/ProjectProposalFactory.php
Normal file
26
database/factories/ProjectProposalFactory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ProjectProposal>
|
||||
*/
|
||||
class ProjectProposalFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'einundzwanzig_pleb_id' => \App\Models\EinundzwanzigPleb::factory(),
|
||||
'name' => $this->faker->sentence(3),
|
||||
'description' => $this->faker->paragraph(),
|
||||
'support_in_sats' => $this->faker->numberBetween(10000, 1000000),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user