public function testShouldCommitTheAggregateRootChanges()
 {
     // This is kind of a functional test though.
     $aggregateRoot = EventSourcedAggregateRootStub::create(new AggregateRootIdentifierStub('identifier'));
     $repository = $this->getMock('RayRutjes\\DomainFoundation\\Repository\\Repository');
     $callback = new SimpleSaveAggregateCallback($repository);
     $callback->save($aggregateRoot);
     $this->assertTrue($aggregateRoot->uncommittedChanges()->isEmpty());
 }
 public function testItCanRegisterAnAggregateRoot()
 {
     $aggregateRoot = EventSourcedAggregateRootStub::createWithoutIdentifier();
     $eventBus = new SimpleEventBus();
     $callback = $this->getMock('RayRutjes\\DomainFoundation\\UnitOfWork\\SaveAggregateCallback');
     $this->registeredAggregates->expects($this->once())->method('add')->with($this->identicalTo($aggregateRoot), $this->identicalTo($eventBus, $this->identicalTo($callback)));
     $this->assertSame($aggregateRoot, $this->unitOfWork->registerAggregate($aggregateRoot, $eventBus, $callback));
 }
 public function testAppendAggregateRootChangesToTheEventStore()
 {
     $aggregateRoot = EventSourcedAggregateRootStub::create(new AggregateRootIdentifierStub('identifier'));
     $this->eventStore->expects($this->once())->method('append')->with($this->identicalTo($this->aggregateRootType), $this->isInstanceOf('RayRutjes\\DomainFoundation\\Domain\\Event\\Stream\\EventStream'));
     $this->repository->doSave($aggregateRoot);
 }
 public function testShouldNotConsiderAggregateRootsTheSameIfTheImplementationsDiffer()
 {
     $aggregateRoot2 = $this->getMockBuilder('RayRutjes\\DomainFoundation\\Domain\\AggregateRoot\\EventSourcedAggregateRoot')->disableOriginalConstructor()->getMock();
     $this->assertFalse($this->aggregateRoot->sameIdentityAs($aggregateRoot2));
 }