public function testSetGetSubscriptions() { $subscription = new Subscription(); $subscription->setNewsletterId(1)->getSubscriberId(1); $this->model->setSubscriptions($subscription); $this->assertSame([$subscription], $this->model->getSubscriptions()); $this->assertSame($subscription, $this->model->getSubscriptions(1)); }
public function testGetSubscribers() { $newsletterModel = new Newsletter(); $subscriptionModel = new Subscription(); $newsletterModel->setName('Test')->setNewsletterId(1); $subscriptionModel->setNewsletterId(1)->setSubscriberId(1); $newsletterReturnArray = [$newsletterModel]; $subscriptionReturnArray = [$subscriptionModel]; $newsletterServiceMock = $this->getMockBuilder('UthandoNewsletter\\Service\\Newsletter')->disableOriginalConstructor()->getMock(); $subscriptionServiceMock = $this->getMockBuilder('UthandoNewsletter\\Service\\Subscription')->disableOriginalConstructor()->getMock(); $subscriptionMapperMock = $this->getMockBuilder('UthandoNewsletter\\Mapper\\Subscription')->disableOriginalConstructor()->getMock(); $newsletterServiceMock->expects($this->once())->method('fetchVisibleNewsletters')->will($this->returnValue($newsletterReturnArray)); $subscriptionMapperMock->expects($this->once())->method('getSubscriptionsBySubscriberId')->will($this->returnValue($subscriptionReturnArray)); $subscriptionServiceMock->expects($this->once())->method('getMapper')->will($this->returnValue($subscriptionMapperMock)); $this->serviceManager->setAllowOverride(true); $serviceManagerMock = $this->getMockBuilder('UthandoCommon\\Service\\ServiceManager')->disableOriginalConstructor()->getMock(); $serviceManagerMock->expects($this->exactly(2))->method('get')->with($this->logicalOr($this->equalTo('UthandoNewsletter'), $this->equalTo('UthandoNewsletterSubscription')))->will($this->returnValueMap([['UthandoNewsletter', [], true, $newsletterServiceMock], ['UthandoNewsletterSubscription', [], true, $subscriptionServiceMock]])); $this->serviceManager->setService('UthandoServiceManager', $serviceManagerMock); /* @var $form SubscriptionList */ $form = $this->serviceManager->get('FormElementManager')->get('UthandoNewsLetterSubscriptionList'); $form->setOptions($this->options); $form->setLabelPrepend(true); $this->assertSame($this->valueOptions, $form->getSubscribers()); }
public function testSetGetNewsletterId() { $this->model->setNewsletterId(1); $this->assertSame(1, $this->model->getNewsletterId()); }