@@ -63,8 +63,8 @@ protected function setUp(): void
6363 }
6464
6565 /**
66- * @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
6766 * @magentoDataFixture Magento/Sales/_files/quote_with_two_products_and_customer.php
67+ * @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
6868 * @magentoConfigFixture current_store payment/payflowpro/title Some Title Of The Method
6969 * @magentoConfigFixture current_store carriers/freeshipping/title Some Shipping Method
7070 * @magentoDbIsolation enabled
@@ -108,4 +108,51 @@ public function testHandlerWithCustomer(): void
108108
109109 $ this ->assertEquals ($ expectedVars , $ templateVars );
110110 }
111+
112+ /**
113+ * @magentoDataFixture Magento/Sales/_files/quote_with_two_products_and_customer.php
114+ * @magentoConfigFixture cataloginventory/options/enable_inventory_check 0
115+ * @magentoConfigFixture current_store payment/payflowpro/title Some Title Of The Method
116+ * @magentoConfigFixture current_store carriers/freeshipping/title Some Shipping Method
117+ * @magentoDbIsolation enabled
118+ * @magentoAppIsolation enabled
119+ * @return void
120+ */
121+ public function testHandlerWithCustomerWithInventoryCheckDisabled (): void
122+ {
123+ $ errorMessage = __ ('Transaction declined. ' );
124+ $ checkoutType = 'custom_checkout ' ;
125+
126+ $ this ->quote ->load ('test01 ' , 'reserved_order_id ' );
127+ $ this ->cartRepositoryMock ->method ('get ' )
128+ ->with ($ this ->quote ->getId ())
129+ ->willReturn ($ this ->quote );
130+
131+ $ dateAndTime = 'Nov 22, 2019, 1:00:00 AM ' ;
132+ $ this ->localeDateMock ->expects ($ this ->atLeastOnce ())->method ('formatDateTime ' )->willReturn ($ dateAndTime );
133+ $ this ->paymentFailures ->handle ((int )$ this ->quote ->getId (), $ errorMessage ->render ());
134+
135+ $ paymentReflection = new \ReflectionClass ($ this ->paymentFailures );
136+ $ templateVarsMethod = $ paymentReflection ->getMethod ('getTemplateVars ' );
137+ $ templateVarsMethod ->setAccessible (true );
138+
139+ $ templateVars = $ templateVarsMethod ->invoke ($ this ->paymentFailures , $ this ->quote , $ errorMessage , $ checkoutType );
140+ $ expectedVars = [
141+ 'reason ' => $ errorMessage ->render (),
142+ 'checkoutType ' => $ checkoutType ,
143+ 'dateAndTime ' => $ dateAndTime ,
144+ 'customer ' => 'John Smith ' ,
145+ 'customerEmail ' => 'aaa@aaa.com ' ,
146+ 'paymentMethod ' => 'Some Title Of The Method ' ,
147+ 'shippingMethod ' => 'Some Shipping Method ' ,
148+ 'items ' => 'Simple Product x 2.0000 USD 10<br />Custom Design Simple Product x 1.0000 USD 10 ' ,
149+ 'total ' => 'USD 30.0000 ' ,
150+ 'billingAddress ' => $ this ->quote ->getBillingAddress (),
151+ 'shippingAddress ' => $ this ->quote ->getShippingAddress (),
152+ 'billingAddressHtml ' => $ this ->quote ->getBillingAddress ()->format ('html ' ),
153+ 'shippingAddressHtml ' => $ this ->quote ->getShippingAddress ()->format ('html ' ),
154+ ];
155+
156+ $ this ->assertEquals ($ expectedVars , $ templateVars );
157+ }
111158}
0 commit comments