From: Kunal Mehta Date: Sat, 13 Sep 2014 02:31:06 +0000 (-0700) Subject: Add tests for MailAddress X-Git-Tag: 1.31.0-rc.0~14030 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=c1e925012494997e3915896dcc263e7ba10da357;p=lhc%2Fweb%2Fwiklou.git Add tests for MailAddress Change-Id: Ia192919322743854096aceb24be0fcf9b1aa32b4 --- diff --git a/tests/phpunit/includes/mail/MailAddressTest.php b/tests/phpunit/includes/mail/MailAddressTest.php new file mode 100644 index 0000000000..437b135f68 --- /dev/null +++ b/tests/phpunit/includes/mail/MailAddressTest.php @@ -0,0 +1,38 @@ +markTestSkipped( 'This test only works on non-Windows platforms' ); + } + $this->setMwGlobals( 'wgEnotifUseRealName', $useRealName ); + $ma = new MailAddress( $address, $name, $realName ); + $this->assertEquals( $expected, $ma->toString() ); + } + + 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' ), + ); + } + + /** + * @covers MailAddress::__toString + */ + public function test__ToString() { + $ma = new MailAddress( 'some@email.com', 'UserName', 'A real name' ); + $this->assertEquals( $ma->toString(), (string)$ma ); + } + +} \ No newline at end of file