public function testHandleConfirmation()
{
$payment = $this->getMock('Sonata\\Component\\Payment\\PaymentInterface');
$payment->expects($this->once())->method('getOrderReference')->will($this->returnValue('42'));
$payment->expects($this->once())->method('isRequestValid')->will($this->returnValue(true));
$order = $this->getMock('Sonata\\Component\\Order\\OrderInterface');
$om = $this->getMock('Sonata\\Component\\Order\\OrderManagerInterface');
$om->expects($this->once())->method('findOneBy')->will($this->returnValue($order));
$ps = $this->getMock('Sonata\\Component\\Payment\\PaymentSelectorInterface');
$ps->expects($this->exactly(2))->method('getPayment')->will($this->returnValue($payment));
$ref = $this->getMock('Sonata\\Component\\Generator\\ReferenceInterface');
$tm = $this->getMock('Sonata\\Component\\Payment\\TransactionManagerInterface');
$tm->expects($this->once())->method('create')->will($this->returnValue(new Transaction()));
$nb = $this->getMockBuilder('Sonata\\NotificationBundle\\Backend\\RuntimeBackend')->disableOriginalConstructor()->getMock();
$eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$handler = new PaymentHandler($om, $ps, $ref, $tm, $nb, $eventDispatcher);
$request = new Request();
$basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
$confirmOrder = $handler->handleConfirmation($request);
$this->assertEquals($confirmOrder, $order);
}