|
32 | 32 | use Magento\TestFramework\Helper\Xpath;
|
33 | 33 | use Magento\TestFramework\Mail\Template\TransportBuilderMock;
|
34 | 34 | use PHPUnit\Framework\TestCase;
|
35 |
| -use Magento\Newsletter\Model\Subscriber; |
36 |
| -use Magento\Framework\Exception\NoSuchEntityException; |
37 |
| -use Magento\Framework\App\Area; |
38 |
| -use Magento\Framework\Mail\Template\TransportBuilder; |
39 | 35 |
|
40 | 36 | /**
|
41 | 37 | * Tests for customer creation via customer account management service.
|
@@ -759,110 +755,4 @@ private function getCustomTemplateId(string $templateCode): int
|
759 | 755 | ->getFirstItem()
|
760 | 756 | ->getId();
|
761 | 757 | }
|
762 |
| - |
763 |
| - /** |
764 |
| - * @magentoConfigFixture current_store newsletter/general/active 1 |
765 |
| - * @magentoConfigFixture current_store newsletter/subscription/confirm 1 |
766 |
| - * @magentoDataFixture Magento/Customer/_files/customer.php |
767 |
| - * @magentoDataFixture Magento/Newsletter/_files/subscribers.php |
768 |
| - * |
769 |
| - * @return void |
770 |
| - * @throws InputException |
771 |
| - * @throws InputMismatchException |
772 |
| - * @throws LocalizedException |
773 |
| - * @throws NoSuchEntityException |
774 |
| - */ |
775 |
| - public function testCreateAccountWithNewsLetterSubscription() :void |
776 |
| - { |
777 |
| - $customer = $this->customerRepository->getById(1); |
778 |
| - $customerEmail = $customer->getEmail(); |
779 |
| - $customerData = [ |
780 |
| - 'name' => $customer->getFirstname() . ' ' . $customer->getLastname(), |
781 |
| - 'email' => $customerEmail, |
782 |
| - 'id' => $customer->getId(), |
783 |
| - 'rp_token' => 'randomstring' |
784 |
| - ]; |
785 |
| - $this->assertAndSendEmailNotification( |
786 |
| - $customerData, |
787 |
| - $customerEmail, |
788 |
| - 'customer_create_account_email_template', |
789 |
| - null |
790 |
| - ); |
791 |
| - |
792 |
| - /** @var Subscriber $subscriber */ |
793 |
| - $subscriber = $this->objectManager->create(Subscriber::class); |
794 |
| - $subscriber->subscribe($customerEmail); |
795 |
| - $subscriber->confirm($subscriber->getSubscriberConfirmCode()); |
796 |
| - $confirmationLink = $subscriber->getConfirmationLink(); |
797 |
| - |
798 |
| - // Verify if the customer is subscribed to newsletter |
799 |
| - $this->assertTrue($subscriber->isSubscribed()); |
800 |
| - |
801 |
| - $this->assertAndSendEmailNotification( |
802 |
| - $customerData, |
803 |
| - $customerEmail, |
804 |
| - 'newsletter_subscription_confirm_email_template', |
805 |
| - $confirmationLink |
806 |
| - ); |
807 |
| - } |
808 |
| - |
809 |
| - /** |
810 |
| - * @param $customerData |
811 |
| - * @param $customerEmail |
812 |
| - * @param $templateIdentifier |
813 |
| - * @param $confirmationLink |
814 |
| - * @return void |
815 |
| - * @throws LocalizedException |
816 |
| - * @throws \Magento\Framework\Exception\MailException |
817 |
| - */ |
818 |
| - private function assertAndSendEmailNotification( |
819 |
| - $customerData, |
820 |
| - $customerEmail, |
821 |
| - $templateIdentifier, |
822 |
| - $confirmationLink = null |
823 |
| - ) :void { |
824 |
| - /** @var TransportBuilder $transportBuilder */ |
825 |
| - $transportBuilder = $this->objectManager->get(TransportBuilder::class); |
826 |
| - $transport = $transportBuilder->setTemplateIdentifier($templateIdentifier) |
827 |
| - ->setTemplateOptions( |
828 |
| - [ |
829 |
| - 'area' => Area::AREA_FRONTEND, |
830 |
| - 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID |
831 |
| - ] |
832 |
| - ) |
833 |
| - ->setTemplateVars( |
834 |
| - [ |
835 |
| - 'customer' => $customerData, |
836 |
| - 'subscriber_data' => [ |
837 |
| - 'confirmation_link' => $confirmationLink, |
838 |
| - ], |
839 |
| - ] |
840 |
| - ) |
841 |
| - ->addTo($customerEmail) |
842 |
| - ->getTransport(); |
843 |
| - $transport->sendMessage(); |
844 |
| - $sendMessage = $transport->getMessage(); |
845 |
| - $this->assertNotNull($sendMessage); |
846 |
| - |
847 |
| - switch ($templateIdentifier) { |
848 |
| - case 'customer_create_account_email_template': |
849 |
| - $this->assertEquals('Welcome to Default', $sendMessage->getSubject()); |
850 |
| - $this->assertStringContainsString( |
851 |
| - $customerData['name'], |
852 |
| - $sendMessage->getBody()->getParts()[0]->getRawContent() |
853 |
| - ); |
854 |
| - $this->assertStringContainsString( |
855 |
| - $customerData['email'], |
856 |
| - $sendMessage->getBody()->getParts()[0]->getRawContent() |
857 |
| - ); |
858 |
| - break; |
859 |
| - case 'newsletter_subscription_confirm_email_template': |
860 |
| - $this->assertStringContainsString( |
861 |
| - $confirmationLink, |
862 |
| - $sendMessage->getBody()->getParts()[0]->getRawContent() |
863 |
| - ); |
864 |
| - $this->assertEquals('Newsletter subscription confirmation', $sendMessage->getSubject()); |
865 |
| - break; |
866 |
| - } |
867 |
| - } |
868 | 758 | }
|
0 commit comments