public getPaymentCallbackResponse ( |
||
$request |
public function testGetPaymentCallbackResponse() { $response = new Response(); $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)); $payment->expects($this->once())->method('callback')->will($this->returnValue($response)); $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(3))->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(); $handler = new PaymentHandler($om, $ps, $ref, $tm, $nb); $request = new Request(); $cbResponse = $handler->getPaymentCallbackResponse($request); $this->assertEquals($response, $cbResponse); }