test scheduled node belongs to plan
This commit is contained in:
parent
50ecacd46d
commit
fd0ee57149
1 changed files with 27 additions and 2 deletions
|
|
@ -2,11 +2,16 @@
|
|||
|
||||
namespace Tests\Unit\ScheduledNode\UseCases;
|
||||
|
||||
use App\Plan\CreatePlanDto;
|
||||
use App\Plan\Plan;
|
||||
use App\ScheduledNode\ScheduledNode;
|
||||
use App\ScheduledNode\ScheduledNodeRepository;
|
||||
use App\ScheduledNode\UseCases\CreateScheduledNode;
|
||||
use App\ScheduledNode\UseCases\CreateScheduledNodeRequest;
|
||||
use App\User\User;
|
||||
use App\ValueObjects\EmailAddress;
|
||||
use DateTimeImmutable;
|
||||
use Tests\Fakes\FakePlanRepository;
|
||||
use Tests\Fakes\FakeScheduledNodeRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
@ -14,13 +19,21 @@ class CreateScheduledNodeTest extends TestCase
|
|||
{
|
||||
private FakeScheduledNodeRepository $scheduledNodeRepo;
|
||||
|
||||
private FakePlanRepository $planRepo;
|
||||
|
||||
private CreateScheduledNode $useCase;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->scheduledNodeRepo = new FakeScheduledNodeRepository;
|
||||
$this->planRepo = new FakePlanRepository;
|
||||
$this->planRepo->create(new CreatePlanDto(
|
||||
name: 'testplan',
|
||||
user: new User(0, new EmailAddress('test@test.com')),
|
||||
));
|
||||
$this->useCase = new CreateScheduledNode(
|
||||
$this->scheduledNodeRepo
|
||||
$this->scheduledNodeRepo,
|
||||
$this->planRepo,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +41,8 @@ class CreateScheduledNodeTest extends TestCase
|
|||
{
|
||||
$scheduledNode = $this->useCase->execute(
|
||||
new CreateScheduledNodeRequest(
|
||||
date: new DateTimeImmutable('now')
|
||||
date: new DateTimeImmutable('now'),
|
||||
planId: 0,
|
||||
)
|
||||
);
|
||||
$this->assertInstanceOf(ScheduledNode::class, $scheduledNode);
|
||||
|
|
@ -37,4 +51,15 @@ class CreateScheduledNodeTest extends TestCase
|
|||
$this->scheduledNodeRepo
|
||||
);
|
||||
}
|
||||
|
||||
public function test_scheduled_node_belongs_to_plan(): void
|
||||
{
|
||||
$scheduledNode = $this->useCase->execute(
|
||||
new CreateScheduledNodeRequest(
|
||||
date: new DateTimeImmutable('now'),
|
||||
planId: 0,
|
||||
)
|
||||
);
|
||||
$this->assertInstanceOf(Plan::class, $scheduledNode->getPlan());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue