/** * @covers ::setFrom */ public function testSetFromInvalidEmail() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Email \'invalid[at]example.com\' is invalid'); $email = new Email(); $email->setFrom($this->faker->name, 'invalid[at]example.com'); }
/** * @covers ::formatFrom */ public function testFormatFrom() { /** * @var Mailgun $mailgun */ $mailgun = $this->getMockBuilder('Mailgun\\Mailgun')->getMock(); $mailgunAdapter = new MailgunAdapter($mailgun, ''); $reflector = new \ReflectionClass($mailgunAdapter); $method = $reflector->getMethod('formatFrom'); $method->setAccessible(true); $name = $this->faker->name; $emailAddress = $this->faker->email; $email = new Email(); $email->setFrom($name, $emailAddress); $this->assertSame("{$name} <{$emailAddress}>", $method->invoke($mailgunAdapter, $email)); }