Пример #1
0
 /**
  * Tests the sendMessage method with no subject block.
  */
 public function testSendMessageWithNoSubjectBlock()
 {
     $this->twig->expects($this->once())->method('loadTemplate')->will($this->returnValue($this->template));
     $contact = new Contact();
     $contact->setSubject('Subject from object');
     $message = $this->getMockBuilder('\\Swift_Message')->disableOriginalConstructor()->getMock();
     $message->expects($this->once())->method('setSubject')->with($this->equalTo('Subject from object'))->willReturnSelf();
     $message->expects($this->once())->method('setFrom')->willReturnSelf();
     $message->expects($this->once())->method('setTo')->willReturnSelf();
     $this->serviceMailer->expects($this->once())->method('createMessage')->will($this->returnValue($message));
     $this->mailer->expects($this->once())->method('send')->with($this->equalTo($message));
     $this->serviceMailer->sendMessage($contact);
 }
Пример #2
0
 /**
  * Tests the serialize method.
  */
 public function testSerialize()
 {
     $contact = new Contact();
     $contact->setTitle(Contact::TITLE_MR);
     $contact->setFirstName('Rémi');
     $contact->setLastName('Marseille');
     $contact->setEmail('*****@*****.**');
     $contact->setSubject('subject');
     $contact->setMessage('message');
     $contact->setCreatedAt(new \DateTime('2013-07-11T10:07:00+02:00'));
     $expected = 'a:7:{s:5:"title";s:2:"mr";s:9:"firstName";s:5:"Rémi";s:8:"lastName";s:9:"Marseille";s:5:"email";s:24:"*****@*****.**";s:7:"subject";s:7:"subject";s:7:"message";s:7:"message";s:9:"createdAt";s:25:"2013-07-11T10:07:00+02:00";}';
     $this->assertSame($expected, $contact->serialize());
 }