move instantiation of date time immutable to use case. request gets a string
This commit is contained in:
parent
d7fdbc20ee
commit
c32087c35d
4 changed files with 8 additions and 10 deletions
|
|
@ -59,7 +59,7 @@ class CreatePlan
|
||||||
foreach ($nodesOfText as $node) {
|
foreach ($nodesOfText as $node) {
|
||||||
$this->createScheduledNode->execute(
|
$this->createScheduledNode->execute(
|
||||||
new CreateScheduledNodeRequest(
|
new CreateScheduledNodeRequest(
|
||||||
date: new DateTimeImmutable(),
|
date: '2025-01-01', // TODO: this should be cycling over some list of dates
|
||||||
planId: $plan->getId(),
|
planId: $plan->getId(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use App\Plan\PlanRepository;
|
||||||
use App\ScheduledNode\ScheduledNode;
|
use App\ScheduledNode\ScheduledNode;
|
||||||
use App\ScheduledNode\CreateScheduledNodeDto;
|
use App\ScheduledNode\CreateScheduledNodeDto;
|
||||||
use App\ScheduledNode\ScheduledNodeRepository;
|
use App\ScheduledNode\ScheduledNodeRepository;
|
||||||
|
use DateTimeImmutable;
|
||||||
use DomainException;
|
use DomainException;
|
||||||
|
|
||||||
class CreateScheduledNode
|
class CreateScheduledNode
|
||||||
|
|
@ -39,7 +40,7 @@ class CreateScheduledNode
|
||||||
|
|
||||||
return $this->scheduledNodeRepo->create(
|
return $this->scheduledNodeRepo->create(
|
||||||
new CreateScheduledNodeDto(
|
new CreateScheduledNodeDto(
|
||||||
date: $request->date,
|
date: new DateTimeImmutable($request->date),
|
||||||
plan: $plan,
|
plan: $plan,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
namespace App\ScheduledNode\UseCases;
|
namespace App\ScheduledNode\UseCases;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
|
|
||||||
class CreateScheduledNodeRequest
|
class CreateScheduledNodeRequest
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public ?DateTimeImmutable $date,
|
public ?string $date,
|
||||||
public ?int $planId,
|
public ?int $planId,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ use App\ScheduledNode\UseCases\CreateScheduledNode;
|
||||||
use App\ScheduledNode\UseCases\CreateScheduledNodeRequest;
|
use App\ScheduledNode\UseCases\CreateScheduledNodeRequest;
|
||||||
use App\User\User;
|
use App\User\User;
|
||||||
use App\ValueObjects\EmailAddress;
|
use App\ValueObjects\EmailAddress;
|
||||||
use DateTimeImmutable;
|
|
||||||
use DomainException;
|
use DomainException;
|
||||||
use Tests\Fakes\FakePlanRepository;
|
use Tests\Fakes\FakePlanRepository;
|
||||||
use Tests\Fakes\FakeScheduledNodeRepository;
|
use Tests\Fakes\FakeScheduledNodeRepository;
|
||||||
|
|
@ -43,7 +42,7 @@ class CreateScheduledNodeTest extends TestCase
|
||||||
{
|
{
|
||||||
$scheduledNode = $this->useCase->execute(
|
$scheduledNode = $this->useCase->execute(
|
||||||
new CreateScheduledNodeRequest(
|
new CreateScheduledNodeRequest(
|
||||||
date: new DateTimeImmutable('now'),
|
date: '2025-01-01',
|
||||||
planId: 0,
|
planId: 0,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -58,7 +57,7 @@ class CreateScheduledNodeTest extends TestCase
|
||||||
{
|
{
|
||||||
$scheduledNode = $this->useCase->execute(
|
$scheduledNode = $this->useCase->execute(
|
||||||
new CreateScheduledNodeRequest(
|
new CreateScheduledNodeRequest(
|
||||||
date: new DateTimeImmutable('now'),
|
date: '2025-01-01',
|
||||||
planId: 0,
|
planId: 0,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -71,7 +70,7 @@ class CreateScheduledNodeTest extends TestCase
|
||||||
$this->expectExceptionMessage('Plan with id: 1 doesnt exist');
|
$this->expectExceptionMessage('Plan with id: 1 doesnt exist');
|
||||||
$this->useCase->execute(
|
$this->useCase->execute(
|
||||||
new CreateScheduledNodeRequest(
|
new CreateScheduledNodeRequest(
|
||||||
date: new DateTimeImmutable('now'),
|
date: '2025-01-01',
|
||||||
planId: 1,
|
planId: 1,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -97,7 +96,7 @@ class CreateScheduledNodeTest extends TestCase
|
||||||
|
|
||||||
$this->useCase->execute(
|
$this->useCase->execute(
|
||||||
new CreateScheduledNodeRequest(
|
new CreateScheduledNodeRequest(
|
||||||
date: new DateTimeImmutable('now'),
|
date: '2025-01-01',
|
||||||
planId: null,
|
planId: null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue