Пример #1
0
 /**
  * @param \UthandoNewsletter\Model\Subscriber $object
  * @return array
  */
 public function extract($object)
 {
     return ['subscriberId' => $object->getSubscriberId(), 'name' => $object->getName(), 'email' => $object->getEmail(), 'dateCreated' => $this->extractValue('dateCreated', $object->getDateCreated())];
 }
 public function testSetGetSubscribe()
 {
     $this->model->setSubscribe([1 => 2, 2 => 3]);
     $this->assertSame([1 => 2, 2 => 3], $this->model->getSubscribe());
 }
 public function testUpdateSubscriptionsReturnsAffectedRowWhenSubscribing()
 {
     $event = new Event();
     $subscriberModel = new SubscriberModel();
     $subscriberModel->setSubscriberId(1)->setEmail('*****@*****.**')->setName('Joe Bloggs')->setSubscribe([1]);
     $form = $this->getMock('UthandoNewsletter\\Form\\Subscriber');
     $form->expects($this->once())->method('getData')->willReturn($subscriberModel);
     $event->setParams(['form' => $form, 'saved' => 1]);
     $subscriptionServiceMock = $this->getMock('UthandoNewsletter\\Service\\Subscription');
     $subscriptionServiceMock->expects($this->any())->method('getSubscriptionsBySubscriberId')->willReturn([]);
     $subscriptionServiceMock->expects($this->any())->method('save')->willReturn(1);
     $this->serviceManager->get('UthandoServiceManager')->setService('UthandoNewsletterSubscription', $subscriptionServiceMock);
     $service = $this->getService();
     $service->updateSubscriptions($event);
     $this->assertEquals(1, $event->getParam('result'));
 }