6 declare(strict_types=1);
23 private $paymentFailures;
33 private $cartRepositoryMock;
41 $this->cartRepositoryMock = $this->getMockBuilder(CartRepositoryInterface::class)
42 ->disableOriginalConstructor()
44 ->getMockForAbstractClass();
47 PaymentFailuresInterface::class,
49 'cartRepository' => $this->cartRepositoryMock,
64 $errorMessage =
__(
'Transaction declined.');
65 $checkoutType =
'custom_checkout';
67 $this->quote->load(
'test01',
'reserved_order_id');
68 $this->cartRepositoryMock->method(
'get')
69 ->with($this->quote->getId())
70 ->willReturn($this->quote);
72 $this->paymentFailures->handle((
int)$this->quote->getId(), $errorMessage->render());
74 $paymentReflection = new \ReflectionClass($this->paymentFailures);
75 $templateTimeMethod = $paymentReflection->getMethod(
'getLocaleDate');
76 $templateTimeMethod->setAccessible(
true);
78 $templateVarsMethod = $paymentReflection->getMethod(
'getTemplateVars');
79 $templateVarsMethod->setAccessible(
true);
81 $templateVars = $templateVarsMethod->invoke($this->paymentFailures, $this->quote, $errorMessage, $checkoutType);
83 'reason' => $errorMessage,
84 'checkoutType' => $checkoutType,
85 'dateAndTime' => $templateTimeMethod->invoke($this->paymentFailures),
86 'customer' =>
'John Smith',
88 'paymentMethod' =>
'Some Title Of The Method',
89 'shippingMethod' =>
'Some Shipping Method',
90 'items' =>
'Simple Product x 2 USD 10<br />Custom Design Simple Product x 1 USD 10',
91 'total' =>
'USD 30.0000',
92 'billingAddress' => $this->quote->getBillingAddress(),
93 'shippingAddress' => $this->quote->getShippingAddress(),
96 $this->assertEquals($expectedVars, $templateVars);
testHandlerWithCustomer()
static getObjectManager()