X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fmail%2FMailAddressTest.php;h=459f5cc4f53b5cf76d3e04265c17bfcc5dfce0d6;hb=2b28a56d8ac9a2393924a0b201cc39bd86fc4d15;hp=1fc63d901f8bc20f0cc07bd14007112f79599fef;hpb=ea9fcc1e4d3b572199d82c426024e3e5efe23879;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/mail/MailAddressTest.php b/tests/phpunit/includes/mail/MailAddressTest.php index 1fc63d901f..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->getMock( '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() ); } /** @@ -50,16 +50,21 @@ class MailAddressTest extends MediaWikiTestCase { } public static function provideToString() { - return array( - array( true, 'foo@bar.baz', 'FooBar', 'Foo Bar', 'Foo Bar ' ), - array( true, 'foo@bar.baz', 'UserName', null, 'UserName ' ), - array( true, 'foo@bar.baz', 'AUser', 'My real name', 'My real name ' ), - array( true, 'foo@bar.baz', 'A.user.name', 'my@real.name', '"my@real.name" ' ), - array( false, 'foo@bar.baz', 'AUserName', 'Some real name', 'AUserName ' ), - array( false, 'foo@bar.baz', '', '', 'foo@bar.baz' ), - array( true, 'foo@bar.baz', '', '', 'foo@bar.baz' ), - array( true, '', '', '', '' ), - ); + 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', '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', '', '', 'foo@bar.baz' ], + [ true, 'foo@bar.baz', '', '', 'foo@bar.baz' ], + [ true, '', '', '', '' ], + ]; } /**