Наследование: extends BasePayment
 public function testReverseTransform()
 {
     $payment = new PassPayment($this->getMock('Symfony\\Component\\Routing\\RouterInterface'));
     $payment->setCode("paymentCode");
     $pool = $this->getMockBuilder('Sonata\\Component\\Payment\\Pool')->disableOriginalConstructor()->getMock();
     $pool->expects($this->once())->method('getMethod')->will($this->returnValue($payment));
     $transformer = new PaymentMethodTransformer($pool);
     $this->assertEquals($payment, $transformer->reverseTransform("paymentCode"));
 }
Пример #2
0
 public function testPool()
 {
     $pool = new Pool();
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $payment = new PassPayment($router);
     $payment->setCode('pass_1');
     $pool->addMethod($payment);
     $payment = new PassPayment($router);
     $payment->setCode('pass_2');
     $pool->addMethod($payment);
     $payment = new PassPayment($router);
     $payment->setCode('pass_2');
     // same code
     $pool->addMethod($payment);
     $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');
 }
Пример #3
0
 /**
  * useless test ....
  *
  * @return void
  */
 public function testPassPayment()
 {
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $router->expects($this->exactly(2))->method('generate')->will($this->returnValue('http://foo.bar/ok-url'));
     $client = $this->getMock('Buzz\\Client\\ClientInterface');
     $browser = new Browser($client);
     $payment = new PassPayment($router, $browser);
     $payment->setCode('free_1');
     $basket = $this->getMock('Sonata\\Component\\Basket\\Basket');
     $product = $this->getMock('Sonata\\Component\\Product\\ProductInterface');
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->exactly(2))->method('get')->will($this->returnCallback(array($this, 'callback')));
     $transaction->expects($this->once())->method('setTransactionId');
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $order = new PassPaymentTest_Order();
     $order->setCreatedAt($date);
     $this->assertEquals('free_1', $payment->getCode(), 'Pass Payment return the correct code');
     $this->assertTrue($payment->isAddableProduct($basket, $product));
     $this->assertTrue($payment->isBasketValid($basket));
     $this->assertTrue($payment->isRequestValid($transaction));
     $this->assertFalse($payment->isCallbackValid($transaction));
     $this->assertFalse($payment->sendConfirmationReceipt($transaction));
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->assertTrue($payment->isCallbackValid($transaction));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $payment->handleError($transaction));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $payment->sendConfirmationReceipt($transaction));
     $response = $payment->sendbank($order);
     $this->assertTrue($response->headers->has('Location'));
     $this->assertEquals('http://foo.bar/ok-url', $response->headers->get('Location'));
     $this->assertFalse($response->isCacheable());
     $this->assertEquals($payment->getOrderReference($transaction), '0001231');
     $payment->applyTransactionId($transaction);
 }