Skip to content

Commit

Permalink
Merge pull request #1885 from tarlepp/chore(tests)/improve-controller…
Browse files Browse the repository at this point in the history
…-integration-tests

Chore(tests) - Added JSON output asserts to controller integration tests
  • Loading branch information
tarlepp committed Aug 7, 2022
2 parents 6ece9c4 + a7b5998 commit 8b2b1dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/Integration/Controller/HealthzControllerTest.php
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Throwable;
use function sprintf;

/**
* Class HealthzControllerTest
Expand Down Expand Up @@ -67,7 +68,7 @@ public function testThatInvokeMethodIsCallingExpectedMethods(): void
->willReturn(
new JsonResponse(
[
'timestamp' => $healthz->getTimestamp(),
'timestamp' => $healthz->getTimestamp()->format('c'),
],
),
);
Expand All @@ -78,5 +79,12 @@ public function testThatInvokeMethodIsCallingExpectedMethods(): void
self::assertSame(200, $response->getStatusCode());
self::assertNotFalse($content);
self::assertJson($content);
self::assertJsonStringEqualsJsonString(
sprintf(
'{"timestamp": "%s"}',
$healthz->getTimestamp()->format('c'),
),
$content,
);
}
}
1 change: 1 addition & 0 deletions tests/Integration/Controller/IndexControllerTest.php
Expand Up @@ -30,5 +30,6 @@ public function testThatInvokeMethodReturnsExpectedResponse(): void
self::assertSame(200, $response->getStatusCode());
self::assertNotFalse($content);
self::assertJson($content);
self::assertJsonStringEqualsJsonString('{}', $content);
}
}
1 change: 1 addition & 0 deletions tests/Integration/Controller/VersionControllerTest.php
Expand Up @@ -40,5 +40,6 @@ public function testThatInvokeMethodIsCallingExpectedMethods(): void
self::assertSame(200, $response->getStatusCode());
self::assertNotFalse($content);
self::assertJson($content);
self::assertJsonStringEqualsJsonString('{"version": "1.0.0"}', $content);
}
}

0 comments on commit 8b2b1dc

Please sign in to comment.