This commit is contained in:
Carlos Buenosvinos
2022-03-15 09:53:16 +01:00
parent 8e57007572
commit dcad13af81
4 changed files with 16 additions and 18 deletions

View File

@@ -56,7 +56,7 @@ final class CountFollowersQueryHandlerTest extends TestCase
)
);
$expectedReponse = new CountFollowersResponse(
$expectedResponse = new CountFollowersResponse(
authorId: $authorId,
authorUsername: $authorUsername,
numberOfFollowers: $authorFollowers
@@ -67,23 +67,23 @@ 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

View File

@@ -54,16 +54,14 @@ final class CountFollowersProjectionHandlerTest extends TestCase
$redisMock = $this->createMock(\Redis::class);
$redisMock
->expects($this->once())
->method('set')
->method('hmset')
->with(
'author_followers_counter_projection:'.$authorId,
json_encode(
[
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers,
]
)
'author_followers_counter_projection:'.$authorId,
[
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers,
]
)
;

View File

@@ -58,8 +58,8 @@ final class CountFollowersProjectionHandlerTest extends TestCase
$redisMock = $this->createMock(\Redis::class);
$redisMock
->expects($this->once())
->method('set')
->with($redisKey, json_encode($redisRecord));
->method('hmset')
->with($redisKey, $redisRecord);
$dbMock = $this->buildEntityManagerMockReturning($redisRecord);

View File

@@ -25,8 +25,8 @@ final class CreateFollowersCounterProjectionHandlerTest extends TestCase
$redisMock = $this->createMock(\Redis::class);
$redisMock
->expects($this->once())
->method('set')
->with($redisKey, json_encode($redisRecord));
->method('hmset')
->with($redisKey, $redisRecord);
$handler = new CreateFollowersCounterProjectionHandler(
$redisMock,