11
11
use Magento \Checkout \Helper \Data ;
12
12
use Magento \Framework \ObjectManagerInterface ;
13
13
use Magento \Quote \Model \Quote ;
14
- use Magento \Quote \Model \QuoteFactory ;
15
14
use Magento \Quote \Model \QuoteManagement ;
16
15
use Magento \Sales \Api \OrderRepositoryInterface ;
17
16
use Magento \Sales \Model \Order ;
25
24
* Ensures that when a virtual product order fails during payment, the appropriate failure email is
26
25
* sent and does not include any shipping address or method information.
27
26
*
28
- * @magentoAppIsolation enabled
29
27
* @magentoDbIsolation enabled
28
+ * @magentoAppIsolation enabled
30
29
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
31
30
*
32
31
* @AllureSuite("Checkout")
@@ -44,11 +43,6 @@ class DataTest extends TestCase
44
43
*/
45
44
private QuoteManagement $ quoteManagement ;
46
45
47
- /**
48
- * @var QuoteFactory
49
- */
50
- private QuoteFactory $ quoteFactory ;
51
-
52
46
/**
53
47
* @var Data
54
48
*/
@@ -85,7 +79,6 @@ protected function setUp(): void
85
79
86
80
$ this ->objectManager = Bootstrap::getObjectManager ();
87
81
$ this ->quoteManagement = $ this ->objectManager ->get (QuoteManagement::class);
88
- $ this ->quoteFactory = $ this ->objectManager ->get (QuoteFactory::class);
89
82
$ this ->checkoutHelper = $ this ->objectManager ->get (Data::class);
90
83
$ this ->orderRepository = $ this ->objectManager ->get (OrderRepositoryInterface::class);
91
84
$ this ->transportBuilder = $ this ->objectManager ->get (TransportBuilderMock::class);
@@ -103,14 +96,13 @@ protected function setUp(): void
103
96
*/
104
97
public function testSendPaymentFailedEmail (): void
105
98
{
106
- [$ order , $ quote ] = $ this ->prepareOrderFromFixtureQuote ();
99
+ [$ order , $ quote ] = $ this ->createOrderFromFixture ();
107
100
$ this ->simulatePaymentFailure ($ order );
108
101
109
102
$ this ->checkoutHelper ->sendPaymentFailedEmail (
110
103
$ quote ,
111
- (string )__ ('Simulated payment failure ' ),
112
- $ quote ->getPayment ()->getMethod (),
113
- $ quote ->getCheckoutMethod ()
104
+ 'Simulated payment failure ' ,
105
+ $ quote ->getPayment ()->getMethod ()
114
106
);
115
107
116
108
$ message = $ this ->transportBuilder ->getSentMessage ();
@@ -135,6 +127,11 @@ public function testSendPaymentFailedEmail(): void
135
127
$ emailContent ,
136
128
'Shipping method should not appear in the payment failed email for virtual product. '
137
129
);
130
+ $ this ->assertStringContainsString (
131
+ 'Simulated payment failure ' ,
132
+ $ emailContent ,
133
+ 'Expected payment failure message to be present in the email. '
134
+ );
138
135
}
139
136
140
137
/**
@@ -145,7 +142,7 @@ public function testSendPaymentFailedEmail(): void
145
142
*
146
143
* @return array{0: Order, 1: Quote} Returns the created order and the original quote.
147
144
*/
148
- private function prepareOrderFromFixtureQuote (): array
145
+ private function createOrderFromFixture (): array
149
146
{
150
147
/** @var Quote $quote */
151
148
$ quote = $ this ->objectManager ->create (Quote::class)
0 commit comments