update downstream tests for text user requirement
Text now requires a User on construction. seed a user in each test setUp that creates a Text directly or through the fake repository so the suite remains green.
This commit is contained in:
parent
40fdf25da2
commit
cbbbc80326
9 changed files with 71 additions and 22 deletions
|
|
@ -8,10 +8,13 @@ use App\Node\Node;
|
|||
use App\Node\UseCases\BulkCreateNodes;
|
||||
use App\Node\UseCases\BulkCreateNodesRequest;
|
||||
use App\Text\CreateTextDto;
|
||||
use App\User\UseCases\CreateUserDto;
|
||||
use App\ValueObjects\EmailAddress;
|
||||
use DomainException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Tests\Fakes\FakeNodeRepository;
|
||||
use Tests\Fakes\FakeTextRepository;
|
||||
use Tests\Fakes\FakeUserRepository;
|
||||
|
||||
class BulkCreateNodesTest extends TestCase
|
||||
{
|
||||
|
|
@ -22,8 +25,14 @@ class BulkCreateNodesTest extends TestCase
|
|||
|
||||
public function setUp(): void
|
||||
{
|
||||
$userRepo = new FakeUserRepository();
|
||||
$user = $userRepo->create(new CreateUserDto(
|
||||
email: new EmailAddress('a@b.com'),
|
||||
passwordHash: '',
|
||||
isAdmin: false,
|
||||
));
|
||||
$this->textRepo = new FakeTextRepository();
|
||||
$this->textRepo->create(new CreateTextDto(name: 'text'));
|
||||
$this->textRepo->create(new CreateTextDto(name: 'text', user: $user));
|
||||
|
||||
$this->nodeRepo = new FakeNodeRepository();
|
||||
$text = $this->textRepo->find(0);
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@ use App\Node\UseCases\CreateNode;
|
|||
use App\Node\UseCases\CreateNodeRequest;
|
||||
use App\Text\CreateTextDto;
|
||||
use App\Text\Text;
|
||||
use App\User\UseCases\CreateUserDto;
|
||||
use App\ValueObjects\EmailAddress;
|
||||
use DomainException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Tests\Fakes\FakeNodeRepository;
|
||||
use Tests\Fakes\FakeTextRepository;
|
||||
use Tests\Fakes\FakeUserRepository;
|
||||
|
||||
class CreateNodeTest extends TestCase
|
||||
{
|
||||
|
|
@ -22,9 +25,16 @@ class CreateNodeTest extends TestCase
|
|||
|
||||
public function setUp(): void
|
||||
{
|
||||
$userRepo = new FakeUserRepository();
|
||||
$user = $userRepo->create(new CreateUserDto(
|
||||
email: new EmailAddress('a@b.com'),
|
||||
passwordHash: '',
|
||||
isAdmin: false,
|
||||
));
|
||||
$this->textRepo = new FakeTextRepository();
|
||||
$this->textRepo->create(new CreateTextDto(
|
||||
name: 'text'
|
||||
name: 'text',
|
||||
user: $user,
|
||||
));
|
||||
$this->nodeRepo = new FakeNodeRepository();
|
||||
$this->useCase = new CreateNode(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class CreatePlanTest extends TestCase
|
|||
$this->textRepo = new FakeTextRepository();
|
||||
$this->nodeRepo = new FakeNodeRepository();
|
||||
$this->scheduledNodeRepo = new FakeScheduledNodeRepository();
|
||||
$this->userRepo->create(new CreateUserDto(
|
||||
$user = $this->userRepo->create(new CreateUserDto(
|
||||
email: new EmailAddress('test@test.com'),
|
||||
passwordHash: '',
|
||||
isAdmin: false,
|
||||
|
|
@ -47,7 +47,10 @@ class CreatePlanTest extends TestCase
|
|||
planRepo: $this->planRepo,
|
||||
nodeRepo: $this->nodeRepo,
|
||||
);
|
||||
$this->textRepo->create(new CreateTextDto('testname'));
|
||||
$this->textRepo->create(new CreateTextDto(
|
||||
name: 'testname',
|
||||
user: $user,
|
||||
));
|
||||
$this->useCase = new CreatePlan(
|
||||
$this->planRepo,
|
||||
$this->userRepo,
|
||||
|
|
|
|||
|
|
@ -35,19 +35,20 @@ class CreateScheduledNodeTest extends TestCase
|
|||
$this->scheduledNodeRepo = new FakeScheduledNodeRepository();
|
||||
$this->planRepo = new FakePlanRepository();
|
||||
$this->nodeRepo = new FakeNodeRepository();
|
||||
$user = new User(
|
||||
id: 0,
|
||||
email: new EmailAddress('test@test.com'),
|
||||
passwordHash: 'hashed:password1',
|
||||
isAdmin: false,
|
||||
);
|
||||
$this->nodeRepo->create(new CreateNodeDto(
|
||||
text: new Text(0, 'text name'),
|
||||
text: new Text(0, 'text name', $user),
|
||||
title: 'test node',
|
||||
parentNode: null,
|
||||
));
|
||||
$this->planRepo->create(new CreatePlanDto(
|
||||
name: 'testplan',
|
||||
user: new User(
|
||||
id: 0,
|
||||
email: new EmailAddress('test@test.com'),
|
||||
passwordHash: 'hashed:password1',
|
||||
isAdmin: false,
|
||||
),
|
||||
user: $user,
|
||||
));
|
||||
$this->useCase = new CreateScheduledNode(
|
||||
$this->scheduledNodeRepo,
|
||||
|
|
|
|||
|
|
@ -29,19 +29,21 @@ class GetTodaysScheduleTest extends TestCase
|
|||
|
||||
private GetTodaysSchedule $useCase;
|
||||
|
||||
private \App\User\User $user;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->userRepo = new FakeUserRepository();
|
||||
$this->scheduledNodeRepo = new FakeScheduledNodeRepository();
|
||||
$this->planRepo = new FakePlanRepository();
|
||||
$user = $this->userRepo->create(new CreateUserDto(
|
||||
$this->user = $this->userRepo->create(new CreateUserDto(
|
||||
email: new EmailAddress('email@email.com'),
|
||||
passwordHash: 'hash',
|
||||
isAdmin: false,
|
||||
));
|
||||
$plan = $this->planRepo->create(new CreatePlanDto(
|
||||
name: 'test plan',
|
||||
user: $user,
|
||||
user: $this->user,
|
||||
));
|
||||
$this->scheduledNodeRepo->create(new CreateScheduledNodeDto(
|
||||
date: new DateTimeImmutable('2025-01-02'),
|
||||
|
|
@ -49,7 +51,7 @@ class GetTodaysScheduleTest extends TestCase
|
|||
node: new Node(
|
||||
id: 0,
|
||||
title: 'test node',
|
||||
text: new Text(id: 0, name: 'test text'),
|
||||
text: new Text(id: 0, name: 'test text', user: $this->user),
|
||||
parentNode: null,
|
||||
),
|
||||
));
|
||||
|
|
@ -79,7 +81,7 @@ class GetTodaysScheduleTest extends TestCase
|
|||
node: new Node(
|
||||
id: 0,
|
||||
title: 'test node',
|
||||
text: new Text(id: 0, name: 'test text'),
|
||||
text: new Text(id: 0, name: 'test text', user: $this->user),
|
||||
parentNode: null,
|
||||
),
|
||||
));
|
||||
|
|
@ -99,7 +101,7 @@ class GetTodaysScheduleTest extends TestCase
|
|||
node: new Node(
|
||||
id: 0,
|
||||
title: 'test node',
|
||||
text: new Text(id: 0, name: 'test text'),
|
||||
text: new Text(id: 0, name: 'test text', user: $this->user),
|
||||
parentNode: null,
|
||||
),
|
||||
)
|
||||
|
|
@ -172,7 +174,7 @@ class GetTodaysScheduleTest extends TestCase
|
|||
node: new Node(
|
||||
id: 0,
|
||||
title: 'future node',
|
||||
text: new Text(id: 0, name: 'test text'),
|
||||
text: new Text(id: 0, name: 'test text', user: $this->user),
|
||||
parentNode: null,
|
||||
),
|
||||
));
|
||||
|
|
@ -202,7 +204,7 @@ class GetTodaysScheduleTest extends TestCase
|
|||
node: new Node(
|
||||
id: 0,
|
||||
title: 'other node',
|
||||
text: new Text(id: 0, name: 'test text'),
|
||||
text: new Text(id: 0, name: 'test text', user: $otherUser),
|
||||
parentNode: null,
|
||||
),
|
||||
));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue