/** * @covers ::setTo */ public function testSetToInvalidEmail() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Email \'invalid[at]example.com\' is invalid'); $email = new Email(); $email->setTo('to', $this->faker->name, 'invalid[at]example.com'); }
/** * @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)); }