X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fmail%2FMailAddressTest.php;h=459f5cc4f53b5cf76d3e04265c17bfcc5dfce0d6;hp=c837d26f5b5847c7590d71d14e0f8e01d41daf69;hb=2ed1d8cd6149aa2ea904bed82163ac3727fa8e08;hpb=2dd58ade75d15a5895c0c010e17b6f729a0f72fe diff --git a/tests/phpunit/includes/mail/MailAddressTest.php b/tests/phpunit/includes/mail/MailAddressTest.php index c837d26f5b..459f5cc4f5 100644 --- a/tests/phpunit/includes/mail/MailAddressTest.php +++ b/tests/phpunit/includes/mail/MailAddressTest.php @@ -7,7 +7,7 @@ class MailAddressTest extends MediaWikiTestCase { */ public function testConstructor() { $ma = new MailAddress( 'foo@bar.baz', 'UserName', 'Real name' ); - $this->assertInstanceOf( 'MailAddress', $ma ); + $this->assertInstanceOf( MailAddress::class, $ma ); } /** @@ -17,7 +17,7 @@ class MailAddressTest extends MediaWikiTestCase { if ( wfIsWindows() ) { $this->markTestSkipped( 'This test only works on non-Windows platforms' ); } - $user = $this->createMock( 'User' ); + $user = $this->createMock( User::class ); $user->expects( $this->any() )->method( 'getName' )->will( $this->returnValue( 'UserName' ) ); @@ -29,11 +29,11 @@ class MailAddressTest extends MediaWikiTestCase { ); $ma = MailAddress::newFromUser( $user ); - $this->assertInstanceOf( 'MailAddress', $ma ); + $this->assertInstanceOf( MailAddress::class, $ma ); $this->setMwGlobals( 'wgEnotifUseRealName', true ); - $this->assertEquals( 'Real name ', $ma->toString() ); + $this->assertEquals( '"Real name" ', $ma->toString() ); $this->setMwGlobals( 'wgEnotifUseRealName', false ); - $this->assertEquals( 'UserName ', $ma->toString() ); + $this->assertEquals( '"UserName" ', $ma->toString() ); } /** @@ -51,11 +51,16 @@ class MailAddressTest extends MediaWikiTestCase { public static function provideToString() { return [ - [ true, 'foo@bar.baz', 'FooBar', 'Foo Bar', 'Foo Bar ' ], - [ true, 'foo@bar.baz', 'UserName', null, 'UserName ' ], - [ true, 'foo@bar.baz', 'AUser', 'My real name', 'My real name ' ], + [ true, 'foo@bar.baz', 'FooBar', 'Foo Bar', '"Foo Bar" ' ], + [ true, 'foo@bar.baz', 'UserName', null, '"UserName" ' ], + [ true, 'foo@bar.baz', 'AUser', 'My real name', '"My real name" ' ], + [ true, 'foo@bar.baz', 'AUser', 'My "real" name', '"My \"real\" name" ' ], + [ true, 'foo@bar.baz', 'AUser', 'My "A/B" test', '"My \"A/B\" test" ' ], + [ true, 'foo@bar.baz', 'AUser', 'E=MC2', '=?UTF-8?Q?E=3DMC2?= ' ], + // A backslash (\) should be escaped (\\). In a string literal that is \\\\ (4x). + [ true, 'foo@bar.baz', 'AUser', 'My "B\C" test', '"My \"B\\\\C\" test" ' ], [ true, 'foo@bar.baz', 'A.user.name', 'my@real.name', '"my@real.name" ' ], - [ false, 'foo@bar.baz', 'AUserName', 'Some real name', 'AUserName ' ], + [ false, 'foo@bar.baz', 'AUserName', 'Some real name', '"AUserName" ' ], [ false, 'foo@bar.baz', '', '', 'foo@bar.baz' ], [ true, 'foo@bar.baz', '', '', 'foo@bar.baz' ], [ true, '', '', '', '' ],