|
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
8 |
| -use Magento\Newsletter\Model\SubscriberFactory; |
| 8 | +use Magento\Customer\Api\CustomerRepositoryInterface; |
| 9 | +use Magento\Newsletter\Model\Subscriber; |
9 | 10 | use Magento\TestFramework\Helper\Bootstrap;
|
10 | 11 | use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
|
11 | 12 |
|
12 | 13 | Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/three_customers.php');
|
13 | 14 |
|
14 | 15 | $objectManager = Bootstrap::getObjectManager();
|
15 |
| -$subscriberFactory = $objectManager->get(SubscriberFactory::class); |
| 16 | +$customerRepository = $objectManager->create(CustomerRepositoryInterface::class); |
16 | 17 |
|
17 |
| -$subscriberFactory->create()->subscribe('customer@search.example.com'); |
18 |
| -$subscriberFactory->create()->subscribe('customer2@search.example.com'); |
19 |
| -$subscriberFactory->create()->subscribe('customer3@search.example.com'); |
| 18 | +$customer1 = $customerRepository->get('customer@search.example.com'); |
| 19 | +$subscriber1 = $objectManager->create(Subscriber::class); |
| 20 | +$subscriber1->setStoreId($customer1->getStoreId()) |
| 21 | + ->setCustomerId($customer1->getId()) |
| 22 | + ->setSubscriberEmail('customer@example.com') |
| 23 | + ->setSubscriberStatus(Subscriber::STATUS_SUBSCRIBED) |
| 24 | + ->save(); |
| 25 | + |
| 26 | +$customer2 = $customerRepository->get('customer2@search.example.com'); |
| 27 | +$subscriber2 = $objectManager->create(Subscriber::class); |
| 28 | +$subscriber2->setStoreId($customer2->getStoreId()) |
| 29 | + ->setCustomerId($customer2->getId()) |
| 30 | + ->setSubscriberEmail('customer2@search.example.com') |
| 31 | + ->setSubscriberStatus(Subscriber::STATUS_SUBSCRIBED) |
| 32 | + ->save(); |
| 33 | + |
| 34 | +$customer3 = $customerRepository->get('customer3@search.example.com'); |
| 35 | +$subscriber3 = $objectManager->create(Subscriber::class); |
| 36 | +$subscriber3->setStoreId($customer3->getStoreId()) |
| 37 | + ->setCustomerId($customer3->getId()) |
| 38 | + ->setSubscriberEmail('customer3@search.example.com') |
| 39 | + ->setSubscriberStatus(Subscriber::STATUS_SUBSCRIBED) |
| 40 | + ->save(); |
0 commit comments