コード例 #1
0
ファイル: IntegrationTest.php プロジェクト: potfur/journal
 public function testRootWillBeReconstitutedFromStream()
 {
     $contract = Contract::fromClass(AggregateRootDouble::class);
     $eventStreamId = EventStreamIdentifier::fromString('test');
     $event = $this->getMock(DomainEvent::class);
     $this->persistence->expects($this->any())->method('fetch')->willReturn([$event]);
     $aggregate = $this->uow->get($contract, $eventStreamId);
     $this->assertEquals([$event], iterator_to_array($aggregate->events));
 }
コード例 #2
0
ファイル: UnitOfWorkTest.php プロジェクト: potfur/journal
 public function testCommitStreamWithoutChanges()
 {
     $contract = Contract::fromClass(static::class);
     $identifier = EventStreamIdentifier::fromString('foo');
     $root = $this->getMock(AggregateRoot::class);
     $root->expects($this->any())->method('getRecordedEvents')->willReturn([]);
     $this->persistence->expects($this->any())->method('fetch')->willReturn([]);
     $this->persistence->expects($this->never())->method('commit');
     $this->eventEmitter->expects($this->never())->method('emit');
     $this->uow->track($contract, $identifier, $root);
     $this->uow->commit();
 }