Ejemplo n.º 1
0
 public function getEvents(UUID $aggregateId)
 {
     $s = $this->db->prepare("SELECT\n                *\n            FROM\n                events\n            WHERE\n                aggregate_id = :aggregateId\n            AND\n                event_stream_version = :eventStreamVersion\n            ORDER BY\n                version ASC");
     $s->execute(array(':aggregateId' => $aggregateId->value(), ':eventStreamVersion' => self::EVENT_STREAM_VERSION));
     $rows = $s->fetchAll();
     $events = array();
     foreach ($rows as $row) {
         $events[] = unserialize($row['data']);
     }
     return $events;
 }
 public function test()
 {
     $originatingVersion = 1;
     $newName = 'testNewName';
     $roomId = new UUID();
     $room = $this->getMockBuilder('\\connected\\reservation\\domain\\model\\room\\Room')->setConstructorArgs(array(new RoomCreated($roomId, 'testName', 2)))->getMock();
     $room->expects($this->once())->method('changeName')->with($newName);
     $repository = $this->getMock('\\connected\\reservation\\domain\\model\\room\\RoomRepository');
     $repository->expects($this->at(0))->method('getById')->willReturn($room);
     $repository->expects($this->at(1))->method('save');
     (new ChangeRoomNameCommandHandler($repository))->handle(new ChangeRoomNameCommand($originatingVersion, $roomId->value(), $newName));
 }