diff --git a/tests/e2e/Controllers/NodeControllerTest.php b/tests/e2e/Controllers/NodeControllerTest.php index 28f0932..ab01495 100644 --- a/tests/e2e/Controllers/NodeControllerTest.php +++ b/tests/e2e/Controllers/NodeControllerTest.php @@ -8,6 +8,7 @@ use App\Node\UseCases\CreateNode; use App\Text\CreateTextDto; 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; @@ -92,13 +93,15 @@ class NodeControllerTest extends TestCase parentNode: null, )); + $body = (new StreamFactory())->createStream(json_encode([ + 'textId' => 0, + 'title' => 'Child Node', + 'parentNodeId' => $rootNode->getId(), + ])); $request = (new ServerRequestFactory()) ->createServerRequest('POST', 'http://localhost/api/nodes') - ->withParsedBody([ - 'textId' => 0, - 'title' => 'Child Node', - 'parentNodeId' => $rootNode->getId(), - ]); + ->withHeader('Content-Type', 'application/json') + ->withBody($body); $response = $this->controller->createNode( $request, @@ -115,12 +118,14 @@ class NodeControllerTest extends TestCase public function test_create_node_returns_400_when_title_missing(): void { + $body = (new StreamFactory())->createStream(json_encode([ + 'textId' => 0, + 'parentNodeId' => null, + ])); $request = (new ServerRequestFactory()) ->createServerRequest('POST', 'http://localhost/api/nodes') - ->withParsedBody([ - 'textId' => 0, - 'parentNodeId' => null, - ]); + ->withHeader('Content-Type', 'application/json') + ->withBody($body); $response = $this->controller->createNode( $request, @@ -133,13 +138,15 @@ class NodeControllerTest extends TestCase public function test_create_node_returns_404_when_text_not_found(): void { + $body = (new StreamFactory())->createStream(json_encode([ + 'textId' => 99, + 'title' => 'Some Node', + 'parentNodeId' => null, + ])); $request = (new ServerRequestFactory()) ->createServerRequest('POST', 'http://localhost/api/nodes') - ->withParsedBody([ - 'textId' => 99, - 'title' => 'Some Node', - 'parentNodeId' => null, - ]); + ->withHeader('Content-Type', 'application/json') + ->withBody($body); $response = $this->controller->createNode( $request,