Sonata\Tests\Component\Payment\CheckPaymentTest::testPassPayment PHP Метод

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

...
public testPassPayment ( )
    public function testPassPayment()
    {
        $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
        $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
        $browser = new Browser();
        $payment = new CheckPayment($router, $logger, $browser);
        $payment->setCode('free_1');
        $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 CheckPaymentTest_Order();
        $order->setCreatedAt($date);
        $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');
        $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
        $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->assertEquals($payment->getOrderReference($transaction), '0001231');
        $payment->applyTransactionId($transaction);
    }