test plan has user
This commit is contained in:
parent
66c49e07dd
commit
baa5dee0b3
1 changed files with 24 additions and 1 deletions
|
|
@ -4,25 +4,48 @@ namespace Tests\Unit\Plan\UseCases;
|
||||||
|
|
||||||
use App\Plan\UseCases\CreatePlan;
|
use App\Plan\UseCases\CreatePlan;
|
||||||
use App\Plan\UseCases\CreatePlanRequest;
|
use App\Plan\UseCases\CreatePlanRequest;
|
||||||
|
use App\User\UseCases\CreateUserDto;
|
||||||
|
use App\User\User;
|
||||||
|
use App\User\UserRepository;
|
||||||
|
use App\ValueObjects\EmailAddress;
|
||||||
use Tests\Fakes\FakePlanRepository;
|
use Tests\Fakes\FakePlanRepository;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Tests\Fakes\FakeUserRepository;
|
||||||
|
|
||||||
class CreatePlanTest extends TestCase
|
class CreatePlanTest extends TestCase
|
||||||
{
|
{
|
||||||
private FakePlanRepository $planRepo;
|
private FakePlanRepository $planRepo;
|
||||||
|
private UserRepository $userRepo;
|
||||||
private CreatePlan $useCase;
|
private CreatePlan $useCase;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->planRepo = new FakePlanRepository;
|
$this->planRepo = new FakePlanRepository;
|
||||||
$this->useCase = new CreatePlan($this->planRepo);
|
$this->userRepo = new FakeUserRepository;
|
||||||
|
$this->userRepo->create(new CreateUserDto(
|
||||||
|
email: new EmailAddress('test@test.com'),
|
||||||
|
));
|
||||||
|
$this->useCase = new CreatePlan(
|
||||||
|
$this->planRepo,
|
||||||
|
$this->userRepo,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_create_plan(): void
|
public function test_create_plan(): void
|
||||||
{
|
{
|
||||||
$plan = $this->useCase->execute(new CreatePlanRequest(
|
$plan = $this->useCase->execute(new CreatePlanRequest(
|
||||||
|
userId: 0,
|
||||||
name: 'testPlan',
|
name: 'testPlan',
|
||||||
));
|
));
|
||||||
$this->assertEquals('testPlan', $plan->getName());
|
$this->assertEquals('testPlan', $plan->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_plan_has_user(): void
|
||||||
|
{
|
||||||
|
$plan = $this->useCase->execute(new CreatePlanRequest(
|
||||||
|
userId: 0,
|
||||||
|
name: 'testPlan',
|
||||||
|
));
|
||||||
|
$this->assertInstanceOf(User::class, $plan->getUser());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue