예제 #1
0
 public function testHandlePushesNewEvent()
 {
     $command = $this->makeCommand();
     $identity = rand();
     $event = Mockery::mock('C4tech\\RayEmitter\\Contracts\\Domain\\Event');
     $event->shouldReceive('getId')->withNoArgs()->once()->andReturn($identity);
     $this->subject->shouldReceive('getSequence')->withNoArgs()->once()->andReturn(30);
     $this->subject->shouldReceive('handle')->with($command)->once()->andReturn($event);
     $this->subject->shouldReceive('apply')->with($event)->once();
     EventStore::shouldReceive('saveEvent')->with($event)->once();
     expect(RepositoryStub::handle($command))->equals($identity);
 }
예제 #2
0
 public function testHandleCommits()
 {
     $subject = new Middleware();
     $parameter = 'request';
     $response = 'magic beans';
     $callback = function ($request) use($parameter, $response) {
         expect($request)->equals($parameter);
         return $response;
     };
     DB::shouldReceive('beginTransaction')->withNoArgs()->once();
     EventStore::shouldReceive('publishQueue')->withNoArgs()->once();
     DB::shouldReceive('rollBack')->withNoArgs()->never();
     DB::shouldReceive('commit')->withNoArgs()->once();
     expect($subject->handle('request', $callback))->equals($response);
 }