Exemplo n.º 1
0
 /**
  * To make tests faster, all the non-database intensive tests (i.e. body
  * insertion) are consolidated in here.
  *
  * @return type
  */
 public function testFormattingFunctions()
 {
     // this must be set for tracking image to be inserted
     $this->assertTrue((bool) Yii::app()->absoluteBaseUrl);
     // Test body insertion:
     $this->eml = new InlineEmail();
     $this->eml->message = '<html><head></head><body></body>';
     $contact = $this->contacts('testAnyone');
     $this->eml->to = "\"{$contact->name}\" <{$contact->email}>";
     $this->eml->parseMailingList('to');
     $this->eml->targetModel = $contact;
     $this->eml->insertTrackingImage();
     $this->assertBodyHasTrackingImage(' On case 1: user sumbitting new/blank email without tracking image.');
     $message = $this->eml->message;
     $this->eml = new InlineEmail();
     $this->eml->message = $message;
     $this->eml->to = "\"{$contact->name}\" <{$contact->email}>";
     $this->eml->parseMailingList('to');
     $this->eml->targetModel = $contact;
     $this->eml->insertTrackingImage();
     $this->assertBodyHasTrackingImage(' On case 2: user submitting modified body with preexisting tracking image.');
     // Test the validator parseMailingList: parsing the recipients out of address headers
     $this->eml = new InlineEmail();
     // Put it together and take it apart again:
     $toList = array(array('This That', '*****@*****.**'), array('Fruit Fly', '*****@*****.**'));
     $this->eml->to = implode(', ', array_map(function ($t) {
         return "\"{$t[0]}\" <{$t[1]}>";
     }, $toList));
     $this->eml->parseMailingList('to');
     $this->assertEquals($toList, $this->eml->mailingList['to'], "Failed asserting that the addressee list was parsed properly.");
 }