コード例 #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
ファイル: ContactType.php プロジェクト: rkueny/ContactBundle
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('title', 'choice', array('choices' => Contact::getTitles(), 'expanded' => true, 'label' => 'mremi_contact.form.title'))->add('firstName', 'text', array('label' => 'mremi_contact.form.first_name'))->add('lastName', 'text', array('label' => 'mremi_contact.form.last_name'))->add('email', 'email', array('label' => 'mremi_contact.form.email'));
     if ($subjects = $this->subjectProvider->getSubjects()) {
         $builder->add('subject', 'choice', array('choices' => $subjects, 'label' => 'mremi_contact.form.subject'));
     } else {
         $builder->add('subject', 'text', array('label' => 'mremi_contact.form.subject'));
     }
     $builder->add('message', 'textarea', array('label' => 'mremi_contact.form.message'));
     if ($this->captchaType) {
         $builder->add('captcha', $this->captchaType, array('label' => 'mremi_contact.form.captcha'));
     }
     $builder->add('save', 'submit', array('label' => 'mremi_contact.form_submit'));
 }
コード例 #3
0
ファイル: ContactTest.php プロジェクト: rkueny/ContactBundle
 /**
  * Tests the unserialize method.
  */
 public function testUnserialize()
 {
     $contact = new Contact();
     $contact->unserialize('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('mr', $contact->getTitle());
     $this->assertSame('Rémi', $contact->getFirstName());
     $this->assertSame('Marseille', $contact->getLastName());
     $this->assertSame('*****@*****.**', $contact->getEmail());
     $this->assertSame('subject', $contact->getSubject());
     $this->assertSame('message', $contact->getMessage());
     $this->assertSame('2013-07-11T10:07:00+02:00', $contact->getCreatedAt()->format('c'));
 }