diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index cc143fdc52e3b..b8d7ccf83af7c 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -633,6 +633,8 @@ public function confirm($code) $this->setStatus(self::STATUS_SUBSCRIBED) ->setStatusChanged(true) ->save(); + + $this->sendConfirmationSuccessEmail(); return true; } diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php index 5a4032dc4dffd..7dd96be11bcbe 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php @@ -341,6 +341,21 @@ public function testConfirm() $code = 111; $this->subscriber->setCode($code); $this->resource->expects($this->once())->method('save')->willReturnSelf(); + $storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class) + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); + $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); + $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setTemplateVars')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('setFrom')->willReturnSelf(); + $this->transportBuilder->expects($this->once())->method('addTo')->willReturnSelf(); + $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel); + $storeModel->expects($this->any())->method('getId')->willReturn(1); + $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport); + $transport->expects($this->once())->method('sendMessage')->willReturnSelf(); $this->assertTrue($this->subscriber->confirm($code)); }