コード例 #1
0
 /**
  * @test
  */
 public function shouldRequestGetTransactionDetailsTwice()
 {
     $paymentMock = $this->createPaymentMock();
     $paymentMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf('Payum\\Paypal\\ExpressCheckout\\Nvp\\Request\\Api\\GetTransactionDetails'));
     $paymentMock->expects($this->at(2))->method('execute')->with($this->isInstanceOf('Payum\\Paypal\\ExpressCheckout\\Nvp\\Request\\Api\\GetTransactionDetails'));
     $action = new PaymentDetailsSyncAction();
     $action->setPayment($paymentMock);
     $action->execute(new Sync(array('PAYMENTREQUEST_0_AMT' => 12, 'TOKEN' => 'aToken', 'PAYMENTREQUEST_0_TRANSACTIONID' => 'zeroTransId', 'PAYMENTREQUEST_9_TRANSACTIONID' => 'nineTransId')));
 }
コード例 #2
0
    /**
     * @test
     */
    public function shouldRequestGetTransactionDetailsTwice()
    {
        $paymentMock = $this->createPaymentMock();
        $paymentMock
            ->expects($this->at(1))
            ->method('execute')
            ->with($this->isInstanceOf('Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetTransactionDetails'))
            ->will($this->returnCallback(function (GetTransactionDetails $request) {
                $model = $request->getModel();
                $model['foo'] = 'fooVal';
            }))
        ;
        $paymentMock
            ->expects($this->at(2))
            ->method('execute')
            ->with($this->isInstanceOf('Payum\Paypal\ExpressCheckout\Nvp\Request\Api\GetTransactionDetails'))
            ->will($this->returnCallback(function (GetTransactionDetails $request) {
                $model = $request->getModel();
                $model['bar'] = 'barVal';
            }))
        ;

        $action = new PaymentDetailsSyncAction();
        $action->setPayment($paymentMock);

        $details = new \ArrayObject(array(
            'PAYMENTREQUEST_0_AMT' => 12,
            'TOKEN' => 'aToken',
            'PAYMENTREQUEST_0_TRANSACTIONID' => 'zeroTransId',
            'PAYMENTREQUEST_9_TRANSACTIONID' => 'nineTransId',
        ));

        $action->execute(new Sync($details));

        $this->assertArrayHasKey('foo', (array) $details);
        $this->assertEquals('fooVal', $details['foo']);

        $this->assertArrayHasKey('bar', (array) $details);
        $this->assertEquals('barVal', $details['bar']);
    }