예제 #1
0
 /**
  * @param bool  $hasReminder
  * @param bool  $hasConfig
  * @param bool  $hasRecipient
  * @param bool  $hasSender
  * @param array $templates
  * @return EmailNotification
  */
 protected function createNotification($hasReminder = true, $hasConfig = false, $hasRecipient = false, $hasSender = false, $templates = null)
 {
     $repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $repository->expects($this->any())->method('find')->will($this->returnValue(new CalendarEvent()));
     $templates = is_array($templates) ? $templates : [$this->createTemplate()];
     $repository->expects($this->any())->method('findBy')->will($this->returnValue($templates));
     $this->em->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
     $this->provider = $this->getMockBuilder('\\Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $config = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('has')->will($this->returnValue($hasConfig));
     $config->expects($this->any())->method('get')->will($this->returnValue(self::TEMPLATE));
     $this->provider->expects($this->any())->method('getConfig')->will($this->returnValue($config));
     $notification = new EmailNotification($this->em, $this->provider, $this->entityNameResolver);
     if ($hasReminder) {
         $reminder = new Reminder();
         if (!$hasConfig) {
             $reminder->setRelatedEntityClassName(self::ENTITY)->setRelatedEntityId(1);
         }
         if ($hasRecipient) {
             $user = new User();
             $user->setEmail(self::EMAIL);
             $reminder->setRecipient($user);
         }
         if ($hasSender) {
             $reminder->setSender($this->sender);
         }
         $notification->setReminder($reminder);
     }
     return $notification;
 }