diff --git a/tests/http/stateless/ApplicationCoreTest.php b/tests/http/stateless/ApplicationCoreTest.php index 280309f6..4ea0c5ad 100644 --- a/tests/http/stateless/ApplicationCoreTest.php +++ b/tests/http/stateless/ApplicationCoreTest.php @@ -115,6 +115,13 @@ static function () use (&$sequence): void { $response->getHeaderLine('Content-Type'), "Expected Content-Type 'application/json; charset=UTF-8' for route 'site/index'.", ); + self::assertJsonStringEqualsJsonString( + <<getBody()->getContents(), + "Expected JSON Response body '{\"hello\":\"world\"}'.", + ); self::assertSame( ['before', 'after'], $sequence, @@ -143,6 +150,13 @@ public function testResponseAdapterCachingAndResetBehaviorAcrossMultipleRequests $response1->getHeaderLine('Content-Type'), "Expected Content-Type 'application/json; charset=UTF-8' for route 'site/index'.", ); + self::assertJsonStringEqualsJsonString( + <<getBody()->getContents(), + "Expected JSON Response body '{\"hello\":\"world\"}'.", + ); // access the Response component to test adapter behavior $bridgeResponse1 = $app->response; @@ -340,6 +354,13 @@ public function testSetsPsr7RequestWithStatelessAppStartTimeHeader(): void $response->getHeaderLine('Content-Type'), "Expected Content-Type 'application/json; charset=UTF-8' for route 'site/index'.", ); + self::assertJsonStringEqualsJsonString( + <<getBody()->getContents(), + "Expected JSON Response body '{\"hello\":\"world\"}'.", + ); $psr7Request = $app->request->getPsr7Request(); $statelessAppStartTime = $psr7Request->getHeaderLine('statelessAppStartTime'); @@ -374,6 +395,13 @@ public function testSetWebAndWebrootAliasesAfterHandleRequest(): void $response->getHeaderLine('Content-Type'), "Expected Content-Type 'application/json; charset=UTF-8' for route 'site/index'.", ); + self::assertJsonStringEqualsJsonString( + <<getBody()->getContents(), + "Expected JSON Response body '{\"hello\":\"world\"}'.", + ); self::assertSame( '', Yii::getAlias('@web'), @@ -420,6 +448,13 @@ static function (Event $event) use (&$invocations, &$sequence, &$sender): void { $response->getHeaderLine('Content-Type'), "Expected Content-Type 'application/json; charset=UTF-8' for route 'site/index'.", ); + self::assertJsonStringEqualsJsonString( + <<getBody()->getContents(), + "Expected JSON Response body '{\"hello\":\"world\"}'.", + ); self::assertSame( 1, $invocations, diff --git a/tests/http/stateless/ApplicationTest.php b/tests/http/stateless/ApplicationTest.php index b36a6d59..b1cde9ec 100644 --- a/tests/http/stateless/ApplicationTest.php +++ b/tests/http/stateless/ApplicationTest.php @@ -137,34 +137,6 @@ public function testReturnRedirectResponseForSiteRefreshRoute(): void ); } - /** - * @throws InvalidConfigException if the configuration is invalid or incomplete. - */ - public function testReturnsJsonResponse(): void - { - $app = $this->statelessApplication(); - - $response = $app->handle(FactoryHelper::createServerRequestCreator()->createFromGlobals()); - - self::assertSame( - 200, - $response->getStatusCode(), - "Response 'status code' should be '200' for successful 'StatelessApplication' handling.", - ); - self::assertSame( - 'application/json; charset=UTF-8', - $response->getHeaderLine('Content-Type'), - "Response 'Content-Type' should be 'application/json; charset=UTF-8' for JSON output.", - ); - self::assertSame( - <<getBody()->getContents(), - "Response 'body' should match expected JSON string '{\"hello\":\"world\"}'.", - ); - } - /** * @throws InvalidConfigException if the configuration is invalid or incomplete. */