예제 #1
0
 /**
  * @covers ::setTag
  * @covers ::getTag
  */
 public function testSetTag()
 {
     $email = new Email();
     $tag = $this->faker->text;
     $email->setTag($tag);
     $reflector = new \ReflectionClass($email);
     $tagProperty = $reflector->getProperty('tag');
     $tagProperty->setAccessible(true);
     $this->assertSame($tag, $tagProperty->getValue($email));
     $this->assertSame($tag, $email->getTag());
 }
예제 #2
0
 /**
  * Format 'to' types to be used by the Mailgun API wrapper
  *
  * @param string $type To type: 'to', 'cc' or 'bcc'
  * @param Email  $email
  *
  * @return string Formatted 'to' of type string, Example: 'Bob <*****@*****.**>' (separated by commas for multiple recipients)
  */
 protected function formatToType(string $type, Email $email) : string
 {
     $tos = [];
     foreach ($email->getTo() as $to) {
         if ($to['type'] === $type) {
             $tos[] = "{$to['name']} <{$to['email']}>";
         }
     }
     return implode(', ', $tos);
 }
예제 #3
0
 /**
  * @covers ::formatToType
  */
 public function testFormatToTypeMultiple()
 {
     /**
      * @var Mailgun $mailgun
      */
     $mailgun = $this->getMockBuilder('Mailgun\\Mailgun')->getMock();
     $mailgunAdapter = new MailgunAdapter($mailgun, '');
     $reflector = new \ReflectionClass($mailgunAdapter);
     $method = $reflector->getMethod('formatToType');
     $method->setAccessible(true);
     $names = [$this->faker->name, $this->faker->name];
     $emailAddresses = [$this->faker->email, $this->faker->email];
     $email = new Email();
     $email->setTo('to', $names[0], $emailAddresses[0]);
     $email->setTo('to', $names[1], $emailAddresses[1]);
     $expected = "{$names['0']} <{$emailAddresses['0']}>, {$names['1']} <{$emailAddresses['1']}>";
     $this->assertSame($expected, $method->invoke($mailgunAdapter, 'to', $email));
 }