/** * @return \Orm\Zed\Newsletter\Persistence\SpyNewsletterSubscriberQuery */ public function createNewsletterSubscriberQuery() { return SpyNewsletterSubscriberQuery::create(); }
/** * @return void */ public function testAssignCustomerToExistingSubscriber() { $newsletterSubscriberTransfer = $this->createSubscriber(); $subscriberQuery = SpyNewsletterSubscriberQuery::create(); $subscriberQuery->filterByEmail($newsletterSubscriberTransfer->getEmail()); $subscriberQuery->filterBySubscriberKey($newsletterSubscriberTransfer->getSubscriberKey()); $subscriberEntity = $subscriberQuery->findOneOrCreate(); if ($subscriberEntity->getFkCustomer()) { $subscriberEntity->setFkCustomer(null); } $subscriberEntity->save(); $customerQuery = SpyCustomerQuery::create(); $customerQuery->filterByEmail($newsletterSubscriberTransfer->getEmail()); $customerQuery->filterByCustomerReference('123'); $customer = $customerQuery->findOneOrCreate(); $customer->save(); $newsletterSubscriberTransfer->setFkCustomer($customer->getIdCustomer()); $result = $this->newsletterFacade->assignCustomerToExistingSubscriber($newsletterSubscriberTransfer); $this->assertTrue($result); $queryContainer = new NewsletterQueryContainer(); $subscriberEntity = $queryContainer->querySubscriber()->filterByEmail($newsletterSubscriberTransfer->getEmail())->findOne(); $this->assertSame($customer->getIdCustomer(), $subscriberEntity->getFkCustomer()); }