readonly(s) and some tests fixes
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user