Tests passing
This commit is contained in:
@@ -48,11 +48,11 @@ final class CountFollowersQueryHandlerTest extends TestCase
|
||||
$authorFollowers = 0;
|
||||
$queryHandler = new CountFollowersQueryHandler(
|
||||
$this->buildRedisMockReturning(
|
||||
json_encode([
|
||||
[
|
||||
'id' => $authorId,
|
||||
'username' => $authorUsername,
|
||||
'followers' => $authorFollowers,
|
||||
])
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -89,7 +89,7 @@ final class CountFollowersQueryHandlerTest extends TestCase
|
||||
private function buildRedisMockReturning($fakeReturn): Redis
|
||||
{
|
||||
$mock = $this->createStub(Redis::class);
|
||||
$mock->method('get')->willReturn(
|
||||
$mock->method('hGetAll')->willReturn(
|
||||
$fakeReturn
|
||||
);
|
||||
|
||||
|
||||
@@ -48,15 +48,15 @@ final class CountFollowersQueryHandlerTest extends TestCase
|
||||
$authorFollowers = 0;
|
||||
$queryHandler = new CountFollowersQueryHandler(
|
||||
$this->buildRedisMockReturning(
|
||||
json_encode([
|
||||
[
|
||||
'id' => $authorId,
|
||||
'username' => $authorUsername,
|
||||
'followers' => $authorFollowers,
|
||||
])
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$expectedReponse = new CountFollowersResponse(
|
||||
$expectedResponse = new CountFollowersResponse(
|
||||
authorId: $authorId,
|
||||
authorUsername: $authorUsername,
|
||||
numberOfFollowers: $authorFollowers
|
||||
@@ -67,29 +67,29 @@ final class CountFollowersQueryHandlerTest extends TestCase
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
$expectedReponse->authorId(),
|
||||
$expectedResponse->authorId(),
|
||||
$actualResponse->authorId()
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
$expectedReponse->authorUsername(),
|
||||
$expectedResponse->authorUsername(),
|
||||
$actualResponse->authorUsername()
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
$expectedReponse->numberOfFollowers(),
|
||||
$expectedResponse->numberOfFollowers(),
|
||||
$actualResponse->numberOfFollowers()
|
||||
);
|
||||
|
||||
// In PHPUnit, there is also the chance to
|
||||
// compare the whole content of the object
|
||||
// $this->assertEquals($expectedReponse, $actualResponse);
|
||||
// $this->assertEquals($expectedResponse, $actualResponse);
|
||||
}
|
||||
|
||||
private function buildRedisMockReturning($fakeReturn): Redis
|
||||
{
|
||||
$mock = $this->createStub(Redis::class);
|
||||
$mock->method('get')->willReturn(
|
||||
$mock->method('hGetAll')->willReturn(
|
||||
$fakeReturn
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user