public function testProcessGetRequest()
 {
     $this->request->setMethod('GET');
     $this->request->query->set('gridName', 'testGrid');
     $this->request->query->set('from', '*****@*****.**');
     $this->request->query->set('to', '*****@*****.**');
     $this->request->query->set('subject', 'testSubject');
     $this->nameFormatter->expects($this->any())->method('format')->with($this->isInstanceOf('Oro\\Bundle\\EmailBundle\\Tests\\Unit\\Fixtures\\Entity\\TestUser'))->will($this->returnValue('FirstName LastName'));
     $this->form->expects($this->once())->method('setData')->with($this->model);
     $this->form->expects($this->never())->method('submit');
     $this->assertFalse($this->handler->process($this->model));
     $this->assertEquals('testGrid', $this->model->getGridName());
     $this->assertEquals('FirstName LastName <*****@*****.**>', $this->model->getFrom());
     $this->assertEquals(array('FirstName LastName <*****@*****.**>'), $this->model->getTo());
     $this->assertEquals('testSubject', $this->model->getSubject());
 }
Ejemplo n.º 2
0
 /**
  * @param EmailModel $emailModel
  */
 protected function applyFrom(EmailModel $emailModel)
 {
     if (!$emailModel->getFrom()) {
         if ($this->request->query->has('from')) {
             $from = $this->request->query->get('from');
             if (!empty($from)) {
                 $this->helper->preciseFullEmailAddress($from);
             }
             $emailModel->setFrom($from);
         } else {
             $user = $this->helper->getUser();
             if ($user) {
                 $emailModel->setFrom($this->helper->buildFullEmailAddress($user));
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param EmailModel $model
  *
  * @throws \InvalidArgumentException
  */
 protected function assertModel(EmailModel $model)
 {
     if (!$model->getFrom()) {
         throw new \InvalidArgumentException('Sender can not be empty');
     }
     if (!$model->getTo() && !$model->getCc() && !$model->getBcc()) {
         throw new \InvalidArgumentException('Recipient can not be empty');
     }
 }