/** * Test subscribe. */ public function testUnsubscribeExisting() { $this->assertCount(2, $this->newsletterSubscriptionRepository->findBy(['enabled' => true])); $this->newsletterManager->unSubscribe('*****@*****.**', '123456789'); $this->assertCount(2, $this->newsletterSubscriptionRepository->findAll()); /** * @var LanguageInterface $language */ $language = $this->getRepository('language')->findOneBy(['iso' => 'es']); $reason = 'my reason'; $this->newsletterManager->unSubscribe('*****@*****.**', '123456789', $language, $reason); $this->assertCount(1, $this->newsletterSubscriptionRepository->findBy(['enabled' => true])); $disabledNewsletterSubscription = $this->newsletterSubscriptionRepository->findOneBy(['enabled' => false]); $this->assertEquals($disabledNewsletterSubscription->getReason(), $reason); }
/** * Is subscribed * * @param string $email Email * * @return object|null Subscription instance if exists */ public function getSubscription($email) { return $this->newsletterSubscriptionRepository->findOneBy(['email' => $email]); }