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
|
|
@ -6,6 +6,8 @@ use App\Node\CreateNodeDto;
|
|||
use App\Node\NodeController;
|
||||
use App\Node\UseCases\BulkCreateNodes;
|
||||
use App\Text\CreateTextDto;
|
||||
use App\User\UseCases\CreateUserDto;
|
||||
use App\ValueObjects\EmailAddress;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Psr7\Factory\ServerRequestFactory;
|
||||
|
|
@ -13,6 +15,7 @@ use Slim\Psr7\Factory\StreamFactory;
|
|||
use Slim\Psr7\Response;
|
||||
use Tests\Fakes\FakeNodeRepository;
|
||||
use Tests\Fakes\FakeTextRepository;
|
||||
use Tests\Fakes\FakeUserRepository;
|
||||
|
||||
class BulkCreateNodesControllerTest extends TestCase
|
||||
{
|
||||
|
|
@ -23,8 +26,17 @@ class BulkCreateNodesControllerTest 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();
|
||||
$text = $this->textRepo->create(new CreateTextDto(name: 'test text'));
|
||||
$text = $this->textRepo->create(new CreateTextDto(
|
||||
name: 'test text',
|
||||
user: $user,
|
||||
));
|
||||
|
||||
$this->nodeRepo = new FakeNodeRepository();
|
||||
$this->nodeRepo->create(new CreateNodeDto(
|
||||
|
|
|
|||
|
|
@ -6,12 +6,15 @@ use App\Node\CreateNodeDto;
|
|||
use App\Node\NodeController;
|
||||
use App\Node\UseCases\CreateNode;
|
||||
use App\Text\CreateTextDto;
|
||||
use App\User\UseCases\CreateUserDto;
|
||||
use App\ValueObjects\EmailAddress;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Slim\Psr7\Factory\ServerRequestFactory;
|
||||
use Slim\Psr7\Factory\StreamFactory;
|
||||
use Slim\Psr7\Response;
|
||||
use Tests\Fakes\FakeNodeRepository;
|
||||
use Tests\Fakes\FakeTextRepository;
|
||||
use Tests\Fakes\FakeUserRepository;
|
||||
|
||||
class NodeControllerTest extends TestCase
|
||||
{
|
||||
|
|
@ -21,8 +24,14 @@ class NodeControllerTest 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: 'test text'));
|
||||
$this->textRepo->create(new CreateTextDto(name: 'test text', user: $user));
|
||||
|
||||
$this->nodeRepo = new FakeNodeRepository();
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,10 @@ class PlanControllerTest extends TestCase
|
|||
passwordHash: '',
|
||||
isAdmin: false,
|
||||
));
|
||||
$text = $this->textRepo->create(new CreateTextDto('testname'));
|
||||
$text = $this->textRepo->create(new CreateTextDto(
|
||||
name: 'testname',
|
||||
user: $this->user,
|
||||
));
|
||||
$this->nodeRepo->create(new CreateNodeDto(
|
||||
text: $text,
|
||||
title: 'Root Node',
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class ScheduledNodeControllerTest extends TestCase
|
|||
node: new Node(
|
||||
id: 0,
|
||||
title: $nodeTitle,
|
||||
text: new Text(id: 0, name: 'test text'),
|
||||
text: new Text(id: 0, name: 'test text', user: $user),
|
||||
parentNode: null,
|
||||
),
|
||||
));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue