Sonata\Component\Payment\Ogone\OgonePayment::isBasketValid PHP Метод

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

public isBasketValid ( Sonata\Component\Basket\BasketInterface $basket )
$basket Sonata\Component\Basket\BasketInterface
    public function isBasketValid(BasketInterface $basket)
    {
        return true;
    }

Usage Example

Пример #1
0
 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');
     $router->expects($this->once())->method('generate')->will($this->returnValue('http://www.google.com'));
     $payment = new OgonePayment($router, $logger, $templating, true);
     $payment->setCode('ogone_1');
     $payment->setOptions(array('url_return_ok' => 'sonata_payment_confirmation', 'url_return_ko' => '', 'url_callback' => '', 'template' => '', 'form_url' => '', 'sha_key' => '', 'sha-out_key' => '', 'pspid' => '', 'home_url' => '', 'catalog_url' => ''));
     $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 OgonePaymentTest_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('ogone_1', $payment->getCode(), 'Ogone 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));
 }