adrema/tests/RequestFactories/MembershipRequestFactory.php

64 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2022-11-16 22:59:49 +01:00
<?php
namespace Tests\RequestFactories;
use App\Activity;
2023-02-21 13:02:31 +01:00
use App\Group;
2022-11-16 22:59:49 +01:00
use App\Subactivity;
2022-12-11 21:00:48 +01:00
use Carbon\Carbon;
2022-11-16 22:59:49 +01:00
use Worksome\RequestFactories\RequestFactory;
class MembershipRequestFactory extends RequestFactory
{
public function definition(): array
{
2022-12-11 21:00:48 +01:00
return [
'has_promise' => null,
];
2022-11-16 22:59:49 +01:00
}
public function in(Activity $activity, ?Subactivity $subactivity = null): self
{
return $this->state([
'activity_id' => $activity->id,
'subactivity_id' => $subactivity ? $subactivity->id : null,
]);
}
public function missingAll(): self
{
return $this->state([
'activity_id' => null,
'subactivity_id' => null,
]);
}
public function invalidActivity(): self
{
return $this->state([
'activity_id' => 10000,
'subactivity_id' => null,
]);
}
public function unmatchingSubactivity(): self
{
return $this->state([
'activity_id' => Activity::factory()->create()->id,
'subactivity_id' => Subactivity::factory()->create()->id,
]);
}
2022-12-11 21:00:48 +01:00
public function promise(Carbon $value): self
{
return $this->state([
'promised_at' => $value->format('Y-m-d'),
]);
}
2023-02-21 13:02:31 +01:00
public function group(Group $group): self
{
return $this->state(['group_id' => $group->id]);
}
2022-11-16 22:59:49 +01:00
}