Skip to content

Commit

Permalink
+Add items in PaymentRedirect test
Browse files Browse the repository at this point in the history
  • Loading branch information
hakito committed Feb 29, 2020
1 parent 2b7f478 commit 67d60c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Component/PayPalComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function PaymentRedirect($remittanceIdentifier, $okUrl, $cancelUrl, $desc

$payment = new Payment();
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->setTransactions([$transaction]);
$payment->setIntent('sale');

$this->PayPalPayments->createPayment($remittanceIdentifier, $payment, $okUrl, $cancelUrl);
Expand Down
9 changes: 8 additions & 1 deletion tests/TestCase/Controller/Component/PayPalComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ public function testPaymentRedirectCreatePaymentFails()

public function testPaymentRedirect()
{
$this->PayPal->AddArticle('foo', 2, 1234, 'bar');
$this->PayPal->Shipping = 100;

$this->PayPal->PayPalPayments = $this->getMockForModel('PayPal.PayPalPayments');

$this->PayPal->PayPalPayments->expects($this->once())
->method('createPayment')
->with('ri', $this->anything(), 'https://ok', 'https://cancel')
->with('ri', $this->callback(function($payment) {
$this->assertEquals(29.62 + 1, $payment->getTransactions()[0]->getAmount()->getTotal());
return true;
}), 'https://ok', 'https://cancel')
->will($this->returnCallback(function($remittanceIdentifier, $payment, $okUrl, $cancelUrl){
$links = new \PayPal\Api\Links();
$links
Expand Down

0 comments on commit 67d60c1

Please sign in to comment.