addMethod() 공개 메소드

add a payment method into the pool.
public addMethod ( Sonata\Component\Payment\PaymentInterface $instance )
$instance Sonata\Component\Payment\PaymentInterface
예제 #1
0
파일: PoolTest.php 프로젝트: kinkinweb/lhvb
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Payment handler of class Sonata\Component\Payment\PassPayment must return a code on getCode method. Please refer to the documentation (https://sonata-project.org/bundles/ecommerce/master/doc/reference/bundles/payment/index.html)
  */
 public function testAddMethodError()
 {
     $pool = new Pool();
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $payment = new PassPayment($router);
     $pool->addMethod($payment);
 }
예제 #2
0
 public function testPool()
 {
     $pool = new Pool();
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $delivery = new PassPayment($router);
     $delivery->setCode('pass_1');
     $pool->addMethod($delivery);
     $delivery = new PassPayment($router);
     $delivery->setCode('pass_2');
     $pool->addMethod($delivery);
     $delivery = new PassPayment($router);
     $delivery->setCode('pass_2');
     // same code
     $pool->addMethod($delivery);
     $this->assertEquals(2, count($pool->getMethods()), 'Pool return 2 elements');
     $this->assertInstanceOf('Sonata\\Component\\Payment\\PassPayment', $pool->getMethod('pass_2'), 'Pool return an FreeDelivery Instance');
 }