@@ -31,18 +31,12 @@ class ShipmentSenderTest extends \PHPUnit\Framework\TestCase
31
31
/** @var ObjectManagerInterface */
32
32
private $ objectManager ;
33
33
34
- /** @var State */
35
- private $ state ;
36
-
37
34
/** @var Logger */
38
35
private $ logger ;
39
36
40
37
/** @var int */
41
38
private $ minErrorDefaultValue ;
42
39
43
- /** @var string */
44
- private $ defaultMode ;
45
-
46
40
/**
47
41
* @var CustomerRepository
48
42
*/
@@ -56,9 +50,6 @@ protected function setUp(): void
56
50
parent ::setUp ();
57
51
58
52
$ this ->objectManager = Bootstrap::getObjectManager ();
59
- $ this ->state = $ this ->objectManager ->get (\Magento \Framework \App \State::class);
60
- $ this ->defaultMode = $ this ->state ->getMode ();
61
- $ this ->state ->setMode (State::MODE_DEFAULT );
62
53
$ this ->logger = $ this ->objectManager ->get (Logger::class);
63
54
$ reflection = new \ReflectionClass (get_class ($ this ->logger ));
64
55
$ reflectionProperty = $ reflection ->getProperty ('minimumErrorLevel ' );
@@ -75,7 +66,7 @@ protected function setUp(): void
75
66
*/
76
67
public function testSend ()
77
68
{
78
- $ this ->objectManager ->get (\ Magento \ Framework \ App \ State::class)->setAreaCode ('frontend ' );
69
+ $ this ->objectManager ->get (State::class)->setAreaCode ('frontend ' );
79
70
$ order = $ this ->objectManager ->create (\Magento \Sales \Model \Order::class);
80
71
$ order ->loadByIncrementId ('100000001 ' );
81
72
$ order ->setCustomerEmail ('customer@example.com ' );
@@ -87,7 +78,11 @@ public function testSend()
87
78
$ orderSender = $ this ->objectManager
88
79
->create (\Magento \Sales \Model \Order \Email \Sender \ShipmentSender::class);
89
80
$ result = $ orderSender ->send ($ shipment , true );
90
- $ this ->assertEmpty ($ this ->logger ->getMessages ());
81
+ $ this ->assertFalse (
82
+ array_search (
83
+ 'Environment emulation nesting is not allowed. ' ,
84
+ array_column ($ this ->logger ->getMessages (), 'message ' )
85
+ ));
91
86
$ this ->assertTrue ($ result );
92
87
93
88
$ this ->assertNotEmpty ($ shipment ->getEmailSent ());
@@ -113,7 +108,11 @@ public function testSendWhenCustomerEmailWasModified()
113
108
$ this ->assertEmpty ($ shipment ->getEmailSent ());
114
109
$ result = $ shipmentSender ->send ($ shipment , true );
115
110
116
- $ this ->assertEmpty ($ this ->logger ->getMessages ());
111
+ $ this ->assertFalse (
112
+ array_search (
113
+ 'Environment emulation nesting is not allowed. ' ,
114
+ array_column ($ this ->logger ->getMessages (), 'message ' )
115
+ ));
117
116
$ this ->assertEquals (self ::NEW_CUSTOMER_EMAIL , $ shipmentIdentity ->getCustomerEmail ());
118
117
$ this ->assertTrue ($ result );
119
118
$ this ->assertNotEmpty ($ shipment ->getEmailSent ());
@@ -135,7 +134,11 @@ public function testSendWhenCustomerEmailWasNotModified()
135
134
$ this ->assertEmpty ($ shipment ->getEmailSent ());
136
135
$ result = $ shipmentSender ->send ($ shipment , true );
137
136
138
- $ this ->assertEmpty ($ this ->logger ->getMessages ());
137
+ $ this ->assertFalse (
138
+ array_search (
139
+ 'Environment emulation nesting is not allowed. ' ,
140
+ array_column ($ this ->logger ->getMessages (), 'message ' )
141
+ ));
139
142
$ this ->assertEquals (self ::OLD_CUSTOMER_EMAIL , $ shipmentIdentity ->getCustomerEmail ());
140
143
$ this ->assertTrue ($ result );
141
144
$ this ->assertNotEmpty ($ shipment ->getEmailSent ());
@@ -160,7 +163,11 @@ public function testSendWithoutCustomer()
160
163
$ this ->assertEmpty ($ shipment ->getEmailSent ());
161
164
$ result = $ shipmentSender ->send ($ shipment , true );
162
165
163
- $ this ->assertEmpty ($ this ->logger ->getMessages ());
166
+ $ this ->assertFalse (
167
+ array_search (
168
+ 'Environment emulation nesting is not allowed. ' ,
169
+ array_column ($ this ->logger ->getMessages (), 'message ' )
170
+ ));
164
171
$ this ->assertEquals (self ::ORDER_EMAIL , $ shipmentIdentity ->getCustomerEmail ());
165
172
$ this ->assertTrue ($ result );
166
173
$ this ->assertNotEmpty ($ shipment ->getEmailSent ());
@@ -173,7 +180,7 @@ public function testSendWithoutCustomer()
173
180
*/
174
181
public function testPackages ()
175
182
{
176
- $ this ->objectManager ->get (\ Magento \ Framework \ App \ State::class)->setAreaCode ('frontend ' );
183
+ $ this ->objectManager ->get (State::class)->setAreaCode ('frontend ' );
177
184
$ order = $ this ->objectManager ->create (\Magento \Sales \Model \Order::class);
178
185
$ order ->loadByIncrementId ('100000001 ' );
179
186
$ order ->setCustomerEmail ('customer@example.com ' );
@@ -237,7 +244,5 @@ protected function tearDown(): void
237
244
$ reflectionProperty = new \ReflectionProperty (get_class ($ this ->logger ), 'minimumErrorLevel ' );
238
245
$ reflectionProperty ->setAccessible (true );
239
246
$ reflectionProperty ->setValue ($ this ->logger , $ this ->minErrorDefaultValue );
240
-
241
- $ this ->state ->setMode ($ this ->defaultMode );
242
247
}
243
248
}
0 commit comments