9 $ma =
new MailAddress(
'foo@bar.baz',
'UserName',
'Real name' );
10 $this->assertInstanceOf( MailAddress::class, $ma );
18 $this->markTestSkipped(
'This test only works on non-Windows platforms' );
20 $user = $this->createMock( User::class );
21 $user->expects( $this->
any() )->method(
'getName' )->will(
22 $this->returnValue(
'UserName' )
24 $user->expects( $this->
any() )->method(
'getEmail' )->will(
25 $this->returnValue(
'foo@bar.baz' )
27 $user->expects( $this->
any() )->method(
'getRealName' )->will(
28 $this->returnValue(
'Real name' )
32 $this->assertInstanceOf( MailAddress::class, $ma );
34 $this->assertEquals(
'"Real name" <foo@bar.baz>', $ma->toString() );
36 $this->assertEquals(
'"UserName" <foo@bar.baz>', $ma->toString() );
43 public function testToString( $useRealName, $address, $name, $realName, $expected ) {
45 $this->markTestSkipped(
'This test only works on non-Windows platforms' );
47 $this->
setMwGlobals(
'wgEnotifUseRealName', $useRealName );
48 $ma =
new MailAddress( $address, $name, $realName );
49 $this->assertEquals( $expected, $ma->toString() );
54 [
true,
'foo@bar.baz',
'FooBar',
'Foo Bar',
'"Foo Bar" <foo@bar.baz>' ],
55 [
true,
'foo@bar.baz',
'UserName',
null,
'"UserName" <foo@bar.baz>' ],
56 [
true,
'foo@bar.baz',
'AUser',
'My real name',
'"My real name" <foo@bar.baz>' ],
57 [
true,
'foo@bar.baz',
'AUser',
'My "real" name',
'"My \"real\" name" <foo@bar.baz>' ],
58 [
true,
'foo@bar.baz',
'AUser',
'My "A/B" test',
'"My \"A/B\" test" <foo@bar.baz>' ],
59 [
true,
'foo@bar.baz',
'AUser',
'E=MC2',
'=?UTF-8?Q?E=3DMC2?= <foo@bar.baz>' ],
61 [
true,
'foo@bar.baz',
'AUser',
'My "B\C" test',
'"My \"B\\\\C\" test" <foo@bar.baz>' ],
62 [
true,
'foo@bar.baz',
'A.user.name',
'my@real.name',
'"my@real.name" <foo@bar.baz>' ],
63 [
false,
'foo@bar.baz',
'AUserName',
'Some real name',
'"AUserName" <foo@bar.baz>' ],
64 [
false,
'foo@bar.baz',
'',
'',
'foo@bar.baz' ],
65 [
true,
'foo@bar.baz',
'',
'',
'foo@bar.baz' ],
66 [
true,
'',
'',
'',
'' ],
74 $ma =
new MailAddress(
'some@email.com',
'UserName',
'A real name' );
75 $this->assertEquals( $ma->toString(), (
string)$ma );
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
wfIsWindows()
Check if the operating system is Windows.
testConstructor()
MailAddress::__construct.
testToString( $useRealName, $address, $name, $realName, $expected)
MailAddress::toString provideToString.
test__ToString()
MailAddress::__toString.
testNewFromUser()
MailAddress::newFromUser.
Stores a single person's name and email address.
static newFromUser(User $user)
Create a new MailAddress object for the given user.