isRequestValid() публичный Метод

public isRequestValid ( Sonata\Component\Payment\TransactionInterface $transaction )
$transaction Sonata\Component\Payment\TransactionInterface
Пример #1
0
 /**
  * useless test ....
  *
  * @return void
  */
 public function testValidPayment()
 {
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
     $templating = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface');
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $generator = $this->getMock('Sonata\\Component\\Payment\\Scellius\\ScelliusTransactionGeneratorInterface');
     $payment = new ScelliusPayment($router, $logger, $templating, $generator, true);
     $payment->setCode('free_1');
     $payment->setOptions(array('base_folder' => __DIR__, 'response_command' => 'cat response_ok.txt && echo '));
     $basket = $this->getMock('Sonata\\Component\\Basket\\Basket');
     $product = $this->getMock('Sonata\\Component\\Product\\ProductInterface');
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $order = new ScelliusPaymentTest_Order();
     $order->setCreatedAt($date);
     $order->setId(2);
     $order->setReference('FR');
     $order->setLocale('es');
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'callback')));
     //        $transaction->expects($this->once())->method('setTransactionId');
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $transaction->expects($this->any())->method('getCreatedAt')->will($this->returnValue($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->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);
 }