20
20
use Magento \Framework \Mail \TransportInterface ;
21
21
use Magento \Framework \Reflection \DataObjectProcessor ;
22
22
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
23
+ use Magento \Store \Model \App \Emulation ;
23
24
use Magento \Store \Model \ScopeInterface ;
24
25
use Magento \Store \Model \Store ;
25
26
use Magento \Store \Model \StoreManagerInterface ;
@@ -113,6 +114,10 @@ class EmailNotificationTest extends TestCase
113
114
* @var SenderResolverInterface|MockObject
114
115
*/
115
116
private $ senderResolverMock ;
117
+ /**
118
+ * @var Emulation|MockObject
119
+ */
120
+ private $ emulation ;
116
121
117
122
/**
118
123
* @inheritdoc
@@ -144,6 +149,7 @@ protected function setUp(): void
144
149
->setMethods (['resolve ' ])
145
150
->disableOriginalConstructor ()
146
151
->getMockForAbstractClass ();
152
+ $ this ->emulation = $ this ->createMock (Emulation::class);
147
153
148
154
$ objectManager = new ObjectManagerHelper ($ this );
149
155
@@ -157,6 +163,7 @@ protected function setUp(): void
157
163
'dataProcessor ' => $ this ->dataProcessorMock ,
158
164
'scopeConfig ' => $ this ->scopeConfigMock ,
159
165
'senderResolver ' => $ this ->senderResolverMock ,
166
+ 'emulation ' => $ this ->emulation ,
160
167
]
161
168
);
162
169
}
@@ -336,6 +343,14 @@ public function testEmailNotifyWhenCredentialsChanged(
336
343
$ transport ->expects (clone $ expects )
337
344
->method ('sendMessage ' );
338
345
346
+ $ this ->emulation ->expects (clone $ expects )
347
+ ->method ('startEnvironmentEmulation ' )
348
+ ->willReturnSelf ();
349
+
350
+ $ this ->emulation ->expects (clone $ expects )
351
+ ->method ('stopEnvironmentEmulation ' )
352
+ ->willReturnSelf ();
353
+
339
354
$ this ->model ->credentialsChanged ($ savedCustomer , $ oldEmail , $ isPasswordChanged );
340
355
}
341
356
@@ -498,6 +513,14 @@ public function testPasswordReminder($customerStoreId):void
498
513
['customer ' => $ this ->customerSecureMock , 'store ' => $ this ->storeMock ]
499
514
);
500
515
516
+ $ this ->emulation ->expects ($ this ->once ())
517
+ ->method ('startEnvironmentEmulation ' )
518
+ ->willReturnSelf ();
519
+
520
+ $ this ->emulation ->expects ($ this ->once ())
521
+ ->method ('stopEnvironmentEmulation ' )
522
+ ->willReturnSelf ();
523
+
501
524
$ this ->model ->passwordReminder ($ customerMock );
502
525
}
503
526
@@ -595,6 +618,14 @@ public function testPasswordReminderCustomerWithoutStoreId():void
595
618
self ::STUB_CUSTOMER_NAME ,
596
619
['customer ' => $ this ->customerSecureMock , 'store ' => $ this ->storeMock ]
597
620
);
621
+ $ this ->emulation ->expects ($ this ->once ())
622
+ ->method ('startEnvironmentEmulation ' )
623
+ ->willReturnSelf ();
624
+
625
+ $ this ->emulation ->expects ($ this ->once ())
626
+ ->method ('stopEnvironmentEmulation ' )
627
+ ->willReturnSelf ();
628
+
598
629
$ this ->model ->passwordReminder ($ customer );
599
630
}
600
631
@@ -690,6 +721,13 @@ public function testPasswordResetConfirmation($customerStoreId):void
690
721
self ::STUB_CUSTOMER_NAME ,
691
722
['customer ' => $ this ->customerSecureMock , 'store ' => $ this ->storeMock ]
692
723
);
724
+ $ this ->emulation ->expects ($ this ->once ())
725
+ ->method ('startEnvironmentEmulation ' )
726
+ ->willReturnSelf ();
727
+
728
+ $ this ->emulation ->expects ($ this ->once ())
729
+ ->method ('stopEnvironmentEmulation ' )
730
+ ->willReturnSelf ();
693
731
694
732
$ this ->model ->passwordResetConfirmation ($ customerMock );
695
733
}
@@ -785,6 +823,13 @@ public function testNewAccount($customerStoreId):void
785
823
self ::STUB_CUSTOMER_NAME ,
786
824
['customer ' => $ this ->customerSecureMock , 'back_url ' => '' , 'store ' => $ this ->storeMock ]
787
825
);
826
+ $ this ->emulation ->expects ($ this ->once ())
827
+ ->method ('startEnvironmentEmulation ' )
828
+ ->willReturnSelf ();
829
+
830
+ $ this ->emulation ->expects ($ this ->once ())
831
+ ->method ('stopEnvironmentEmulation ' )
832
+ ->willReturnSelf ();
788
833
789
834
$ this ->model ->newAccount (
790
835
$ customer ,
0 commit comments