1212use Magento \Customer \Model \Session ;
1313use Magento \Framework \Data \Form \FormKey ;
1414use Magento \Framework \Message \MessageInterface ;
15+ use Magento \Newsletter \Model \CustomerSubscriberCache ;
1516use Magento \Newsletter \Model \Plugin \CustomerPlugin ;
1617use Magento \TestFramework \TestCase \AbstractController ;
1718
@@ -69,7 +70,6 @@ protected function tearDown(): void
6970 public function testSaveAction (bool $ isSubscribed , string $ expectedMessage ): void
7071 {
7172 $ this ->loginCustomer ('new_customer@example.com ' );
72- $ this ->_objectManager ->removeSharedInstance (CustomerPlugin::class);
7373 $ this ->dispatchSaveAction ($ isSubscribed );
7474 $ this ->assertSuccessSubscription ($ expectedMessage );
7575 }
@@ -112,7 +112,6 @@ public function testSubscribeWithEnabledConfirmation(): void
112112 public function testUnsubscribeSubscribedCustomer (): void
113113 {
114114 $ this ->loginCustomer ('new_customer@example.com ' );
115- $ this ->_objectManager ->removeSharedInstance (CustomerPlugin::class);
116115 $ this ->dispatchSaveAction (false );
117116 $ this ->assertSuccessSubscription ('We have removed your newsletter subscription. ' );
118117 }
@@ -126,6 +125,7 @@ public function testUnsubscribeSubscribedCustomer(): void
126125 private function dispatchSaveAction (bool $ isSubscribed ): void
127126 {
128127 $ this ->_objectManager ->removeSharedInstance (CustomerPlugin::class);
128+ $ this ->_objectManager ->removeSharedInstance (CustomerSubscriberCache::class);
129129 $ this ->getRequest ()->setParam ('form_key ' , $ this ->formKey ->getFormKey ())
130130 ->setParam ('is_subscribed ' , $ isSubscribed );
131131 $ this ->dispatch ('newsletter/manage/save ' );
0 commit comments