나는 이런 식으로 어떻게 든 내 명령 핸들러를 테스트입니다 :ProMo에서 InMemoryEventStore와 PdoEventStore의 비 호환성 문제를 해결하는 방법은 무엇입니까?
public function testHandle_ShouldPublishFooEvent(): void
{
$fooCommand = $this->givenFooCommand();
$this->whenHandleCommand($fooCommand);
$this->thenFooEventIsPublished();
}
을 기본적으로 명령 핸들러에는 유효성 검사 논리가 없을 때 난 단지 행복 시나리오를 테스트하고있다. 예상 된 이벤트가 이벤트 버스에 게시되었는지 확인하여 테스트합니다. whenHandleCommand 방법에 명령 버스로 테스트 명령을 파견하기 전에, 나는 녹음 이벤트, 같은 파견 시작 :
$eventBus->attach(
EventBus::EVENT_DISPATCH,
function (ActionEvent $actionEvent) use ($events): void {
$event = $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE);
$events->addEvent($event);
},
-1000
);
을하고 결국 난 그냥 기록 된 이벤트를 확인하고 내가 예상 한 내용 있다고 주장한다. 하지만 MysqlEventStore
과 InMemoryEventStore
사이에서 전환하는 데 문제가 있습니다. 왜냐하면 MysqlEventStore
은 트랜잭션이 아니기 때문에 (따라서 saveAggregateRoot
메서드에서 이벤트가 발생합니다) InMemoryEventStore
이 트랜잭션이되어 (따라서 커밋 메소드에서 이벤트가 발생하기 때문에) 문제가됩니다.
class ProophFooRepository extends AggregateRepository implements FooRepository
{
public function save(FooAggregate $foo): void
{
$this->saveAggregateRoot($foo);
}
...
}
방법은 내가 사용하려는 어떤 eventstore (메모리 또는 PDO)를 변경할 수 있으며이 작동 할 수 있도록 만드는 : 저장 방법
내 저장소는 다음과 같이 간단하다? 내 저장소에 조건 if($this->isTransactionalEventStore())
(트랜잭션 및 커밋 시작)이 있어야합니까? 나는 그다지 좋아하지 않는다. ? 해당 InMemoryEventStore가 왜 :(
내가 내 테스트 InMemoryEventStore 실행 원하기 때문에 일반적으로 내가 PdoEventStore을 사용하는 동안, InMemoryTransactionalEventStore
및 InMemoryEventStore
모두가 더 나은해야하지 트랜잭션입니다
편집 :. 내가 변경하는 경우
$wrapper = new ActionEventEmitterEventStore($eventStore, $eventEmitter);
및 확인 InMemoryEventStore
구현 EventStore
대신 TransactionalEventStore
에 InMemoryEventStoreFactory 라인 (100)은, 모든 그러니 어떻게 든 제대로 prooph를 사용하고 있지 않다. 잘 작동 그것은 필요하지 않습니다, 또는 EASI를 고정 할 수 있습니다 PR에 의해 ImMemoryEventStore
에서 InMemoryTransactionalEventStore
및 InMemoryEventStore
으로 나눌 수 있습니까?
물론, 내일 볼 것입니다 :) – Tom