12
12
use Magento \Customer \Model \Session ;
13
13
use Magento \Framework \Data \Form \FormKey ;
14
14
use Magento \Framework \Message \MessageInterface ;
15
+ use Magento \Newsletter \Model \CustomerSubscriberCache ;
15
16
use Magento \Newsletter \Model \Plugin \CustomerPlugin ;
16
17
use Magento \TestFramework \TestCase \AbstractController ;
17
18
@@ -69,7 +70,6 @@ protected function tearDown(): void
69
70
public function testSaveAction (bool $ isSubscribed , string $ expectedMessage ): void
70
71
{
71
72
$ this ->loginCustomer ('new_customer@example.com ' );
72
- $ this ->_objectManager ->removeSharedInstance (CustomerPlugin::class);
73
73
$ this ->dispatchSaveAction ($ isSubscribed );
74
74
$ this ->assertSuccessSubscription ($ expectedMessage );
75
75
}
@@ -112,7 +112,6 @@ public function testSubscribeWithEnabledConfirmation(): void
112
112
public function testUnsubscribeSubscribedCustomer (): void
113
113
{
114
114
$ this ->loginCustomer ('new_customer@example.com ' );
115
- $ this ->_objectManager ->removeSharedInstance (CustomerPlugin::class);
116
115
$ this ->dispatchSaveAction (false );
117
116
$ this ->assertSuccessSubscription ('We have removed your newsletter subscription. ' );
118
117
}
@@ -126,6 +125,7 @@ public function testUnsubscribeSubscribedCustomer(): void
126
125
private function dispatchSaveAction (bool $ isSubscribed ): void
127
126
{
128
127
$ this ->_objectManager ->removeSharedInstance (CustomerPlugin::class);
128
+ $ this ->_objectManager ->removeSharedInstance (CustomerSubscriberCache::class);
129
129
$ this ->getRequest ()->setParam ('form_key ' , $ this ->formKey ->getFormKey ())
130
130
->setParam ('is_subscribed ' , $ isSubscribed );
131
131
$ this ->dispatch ('newsletter/manage/save ' );
0 commit comments