Sonata\Component\Payment\Selector::getPayment PHP Method

getPayment() public method

public getPayment ( $bank )
    public function getPayment($bank)
    {
        if (!array_key_exists($bank, $this->getPaymentPool()->getMethods())) {
            throw new PaymentNotFoundException($bank);
        }
        return $this->getPaymentPool()->getMethod($bank);
    }

Usage Example

Example #1
0
 /**
  * @expectedException \Sonata\Component\Payment\PaymentNotFoundException
  * @expectedExceptionMessage Payment method with code 'not_existing' was not found
  */
 public function testGetPaymentException()
 {
     $paymentPoolMethods = array('first method', 'second method');
     $paymentPool = $this->getMockBuilder('Sonata\\Component\\Payment\\Pool')->getMock();
     $paymentPool->expects($this->any())->method('getMethods')->will($this->returnValue($paymentPoolMethods));
     $productPool = $this->getMockBuilder('Sonata\\Component\\Product\\Pool')->getMock();
     $selector = new Selector($paymentPool, $productPool);
     $selector->getPayment('not_existing');
 }