From c1e925012494997e3915896dcc263e7ba10da357 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 12 Sep 2014 19:31:06 -0700 Subject: [PATCH] Add tests for MailAddress Change-Id: Ia192919322743854096aceb24be0fcf9b1aa32b4 --- .../phpunit/includes/mail/MailAddressTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/phpunit/includes/mail/MailAddressTest.php 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 -- 2.20.1