コード例 #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 testGetReconstitutedWithInvalidContractClass()
 {
     $this->expectException(AggregateIsInvalidInstanceException::class);
     $this->expectExceptionMessage('Aggregate root class StdClass is not instance of ' . AggregateRoot::class);
     $contract = Contract::fromClass(\stdClass::class);
     $identifier = EventStreamIdentifier::fromString('foo');
     $event = $this->GetMock(DomainEvent::class);
     $this->persistence->expects($this->once())->method('fetch')->with($contract, $identifier)->willReturn([$event]);
     $this->uow->get($contract, $identifier);
 }