Skip to content

Commit 397cd22

Browse files
glo23503devarul
authored andcommitted
ACP2E-1341: [On-Premise] Merchant Informed Core Issue Magento 2.4.4 main.ERROR: Environment emulation nesting is not allowed
1 parent 488157b commit 397cd22

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,12 @@ class ShipmentSenderTest extends \PHPUnit\Framework\TestCase
3131
/** @var ObjectManagerInterface */
3232
private $objectManager;
3333

34-
/** @var State */
35-
private $state;
36-
3734
/** @var Logger */
3835
private $logger;
3936

4037
/** @var int */
4138
private $minErrorDefaultValue;
4239

43-
/** @var string */
44-
private $defaultMode;
45-
4640
/**
4741
* @var CustomerRepository
4842
*/
@@ -56,9 +50,6 @@ protected function setUp(): void
5650
parent::setUp();
5751

5852
$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);
6253
$this->logger = $this->objectManager->get(Logger::class);
6354
$reflection = new \ReflectionClass(get_class($this->logger));
6455
$reflectionProperty = $reflection->getProperty('minimumErrorLevel');
@@ -75,7 +66,7 @@ protected function setUp(): void
7566
*/
7667
public function testSend()
7768
{
78-
$this->objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
69+
$this->objectManager->get(State::class)->setAreaCode('frontend');
7970
$order = $this->objectManager->create(\Magento\Sales\Model\Order::class);
8071
$order->loadByIncrementId('100000001');
8172
$order->setCustomerEmail('customer@example.com');
@@ -87,7 +78,11 @@ public function testSend()
8778
$orderSender = $this->objectManager
8879
->create(\Magento\Sales\Model\Order\Email\Sender\ShipmentSender::class);
8980
$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+
));
9186
$this->assertTrue($result);
9287

9388
$this->assertNotEmpty($shipment->getEmailSent());
@@ -113,7 +108,11 @@ public function testSendWhenCustomerEmailWasModified()
113108
$this->assertEmpty($shipment->getEmailSent());
114109
$result = $shipmentSender->send($shipment, true);
115110

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+
));
117116
$this->assertEquals(self::NEW_CUSTOMER_EMAIL, $shipmentIdentity->getCustomerEmail());
118117
$this->assertTrue($result);
119118
$this->assertNotEmpty($shipment->getEmailSent());
@@ -135,7 +134,11 @@ public function testSendWhenCustomerEmailWasNotModified()
135134
$this->assertEmpty($shipment->getEmailSent());
136135
$result = $shipmentSender->send($shipment, true);
137136

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+
));
139142
$this->assertEquals(self::OLD_CUSTOMER_EMAIL, $shipmentIdentity->getCustomerEmail());
140143
$this->assertTrue($result);
141144
$this->assertNotEmpty($shipment->getEmailSent());
@@ -160,7 +163,11 @@ public function testSendWithoutCustomer()
160163
$this->assertEmpty($shipment->getEmailSent());
161164
$result = $shipmentSender->send($shipment, true);
162165

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+
));
164171
$this->assertEquals(self::ORDER_EMAIL, $shipmentIdentity->getCustomerEmail());
165172
$this->assertTrue($result);
166173
$this->assertNotEmpty($shipment->getEmailSent());
@@ -173,7 +180,7 @@ public function testSendWithoutCustomer()
173180
*/
174181
public function testPackages()
175182
{
176-
$this->objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
183+
$this->objectManager->get(State::class)->setAreaCode('frontend');
177184
$order = $this->objectManager->create(\Magento\Sales\Model\Order::class);
178185
$order->loadByIncrementId('100000001');
179186
$order->setCustomerEmail('customer@example.com');
@@ -237,7 +244,5 @@ protected function tearDown(): void
237244
$reflectionProperty = new \ReflectionProperty(get_class($this->logger), 'minimumErrorLevel');
238245
$reflectionProperty->setAccessible(true);
239246
$reflectionProperty->setValue($this->logger, $this->minErrorDefaultValue);
240-
241-
$this->state->setMode($this->defaultMode);
242247
}
243248
}

0 commit comments

Comments
 (0)