-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecipientTest.php
More file actions
66 lines (58 loc) · 1.73 KB
/
RecipientTest.php
File metadata and controls
66 lines (58 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php declare(strict_types=1);
namespace Tests\Mail;
use PHPUnit\Framework\TestCase;
/**
* 测试 php-mailer\Mail\Recipient
*
* @author fdipzone
*/
final class RecipientTest extends TestCase
{
/**
* @covers \Mail\Recipient::__construct
*/
public function testConstruct()
{
$email = 'technology@zone.com';
$name = 'fdipzone';
$recipient = new \Mail\Recipient($email, $name);
$this->assertEquals('Mail\Recipient', get_class($recipient));
}
/**
* @covers \Mail\Recipient::__construct
*/
public function testConstructEmailEmptyException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('mailer recipient: email is empty');
$email = '';
new \Mail\Recipient($email);
}
/**
* @covers \Mail\Recipient::__construct
*/
public function testConstructEmailInvalidException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('mailer recipient: email is invalid');
$email = 'good@good';
new \Mail\Recipient($email);
}
/**
* @covers \Mail\Recipient::__construct
* @covers \Mail\Recipient::email
* @covers \Mail\Recipient::name
*/
public function testGet()
{
$email = 'technology@zone.com';
$name = 'fdipzone';
$recipient = new \Mail\Recipient($email, $name);
$this->assertEquals($email, $recipient->email());
$this->assertEquals($name, $recipient->name());
// 测试不设置收件人名称
$recipient = new \Mail\Recipient($email);
$this->assertEquals($email, $recipient->email());
$this->assertEquals($email, $recipient->name());
}
}