Tests passing

This commit is contained in:
Carlos Buenosvinos
2022-03-15 09:59:08 +01:00
parent dcad13af81
commit 2114a93992
2 changed files with 11 additions and 11 deletions

View File

@@ -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
);

View File

@@ -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
);