readonly(s) and some tests fixes

This commit is contained in:
Carlos Buenosvinos
2022-11-26 19:19:15 +01:00
parent aaeb363b82
commit bf2e9416aa
4 changed files with 18 additions and 13 deletions

View File

@@ -66,7 +66,8 @@
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true,
"symfony/runtime": true
"symfony/runtime": true,
"infection/extension-installer": true
}
},
"autoload": {

View File

@@ -14,9 +14,9 @@ use Cheeper\Chapter7\DomainModel\Follow\FollowRepository;
final class FollowCommandHandler
{
public function __construct(
private AuthorRepository $authors,
private FollowRepository $follows,
private EventBus $eventBus
private readonly AuthorRepository $authors,
private readonly FollowRepository $follows,
private readonly EventBus $eventBus
) {
}
@@ -53,11 +53,11 @@ final class FollowCommandHandler
private function notifyEvents(FollowCommand $command, array $domainEvents): void
{
$stamppedEvents = array_map(
$stampedEvents = array_map(
static fn ($event) => $event->stampAsResponseTo($command),
$domainEvents
);
$this->eventBus->notifyAll($stamppedEvents);
$this->eventBus->notifyAll($stampedEvents);
}
}

View File

@@ -18,8 +18,8 @@ use Cheeper\Chapter7\DomainModel\Author\AuthorRepository;
final class SignUpCommandHandler
{
public function __construct(
private AuthorRepository $authors,
private EventBus $eventBus
private readonly AuthorRepository $authors,
private readonly EventBus $eventBus
) {
}
@@ -72,8 +72,14 @@ final class SignUpCommandHandler
return null !== $inputWebsite ? Website::fromString($inputWebsite) : null;
}
private function signUpAuthor(AuthorId $authorId, UserName $userName, EmailAddress $email, SignUpCommand $command, ?Website $website, ?BirthDate $birthDate): Author
{
private function signUpAuthor(
AuthorId $authorId,
UserName $userName,
EmailAddress $email,
SignUpCommand $command,
?Website $website,
?BirthDate $birthDate)
: Author {
return Author::signUp(
$authorId,
$userName,

View File

@@ -32,8 +32,6 @@ final class SignUpCommandHandlerTest extends TestCase
$this->expectException(AuthorAlreadyExists::class);
$this->expectExceptionMessage('Author with name "johndoe" already exists');
$eventBus = new InMemoryEventBus();
$signUpHandler = new SignUpCommandHandler(
$this->authorRepository,
$this->eventBus
@@ -52,7 +50,7 @@ final class SignUpCommandHandlerTest extends TestCase
)
);
$eventBus->reset();
$this->eventBus->reset();
$signUpHandler(
new SignUpCommand(