diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-10-17 19:15:29 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-10-29 20:13:24 +0300 |
commit | f6f3f3c95d1d212c9ac58cc0a4dec1d369a0fbad (patch) | |
tree | 69ba782ecf337b1188ada2f8bfddf329d9c1ae02 /tests | |
parent | c89121aa5d2b3560a102dd2cb259dd017b5692dc (diff) |
Fix groups expansion on umlauts
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Service/GroupsIntegrationTest.php | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/tests/Service/GroupsIntegrationTest.php b/tests/Service/GroupsIntegrationTest.php index 5fa04f86e..4da789fca 100644 --- a/tests/Service/GroupsIntegrationTest.php +++ b/tests/Service/GroupsIntegrationTest.php @@ -25,10 +25,14 @@ use ChristophWurst\Nextcloud\Testing\TestCase; use OCA\Mail\Service\GroupsIntegration; use OCA\Mail\Service\Group\NextcloudGroupService; use OCA\Mail\Exception\ServiceException; +use PHPUnit\Framework\MockObject\MockObject; class GroupsIntegrationTest extends TestCase { + /** @var NextcloudGroupService|MockObject */ private $groupService1; + + /** @var GroupsIntegration */ private $groupsIntegration; protected function setUp() { @@ -38,7 +42,9 @@ class GroupsIntegrationTest extends TestCase { $this->groupService1->expects($this->any()) ->method('getNamespace') ->willReturn('Namespace1'); - $this->groupsIntegration = new GroupsIntegration($this->groupService1); + $this->groupsIntegration = new GroupsIntegration( + $this->groupService1 + ); } public function testGetMatchingGroups() { @@ -76,7 +82,7 @@ class GroupsIntegrationTest extends TestCase { 'name' => "Bobby", 'email' => "bob@smith.net" ], - [ + [ 'id' => 'mary', 'name' => 'Mary', 'email' => 'mary@smith.net' @@ -102,7 +108,7 @@ class GroupsIntegrationTest extends TestCase { 'name' => "Bobby", 'email' => "bob@smith.net" ], - [ + [ 'id' => 'mary', 'name' => 'Mary', 'email' => 'mary@smith.net' @@ -128,7 +134,7 @@ class GroupsIntegrationTest extends TestCase { 'name' => "Bobby", 'email' => "bob@smith.net" ], - [ + [ 'id' => 'mary', 'name' => 'Mary', 'email' => 'mary@smith.net' @@ -146,6 +152,57 @@ class GroupsIntegrationTest extends TestCase { } + public function testExpandUmlauts() { + $recipients = "john@doe.com,namespace1:ümlaut"; + $members = [ + [ + 'id' => 'bob', + 'name' => "Bobby", + 'email' => "bob@smith.net" + ], + [ + 'id' => 'mary', + 'name' => 'Mary', + 'email' => 'mary@smith.net' + ] + ]; + $this->groupService1->expects($this->once()) + ->method('getUsers') + ->willReturn($members); + + $expected = "john@doe.com,bob@smith.net,mary@smith.net"; + + $actual = $this->groupsIntegration->expand($recipients); + + $this->assertEquals($expected, $actual); + } + + public function testExpandSpace() { + $recipients = "john@doe.com,namespace1:test group"; + $members = [ + [ + 'id' => 'bob', + 'name' => "Bobby", + 'email' => "bob@smith.net" + ], + [ + 'id' => 'mary', + 'name' => 'Mary', + 'email' => 'mary@smith.net' + ] + ]; + $this->groupService1->expects($this->once()) + ->method('getUsers') + ->with('test group') + ->willReturn($members); + + $expected = "john@doe.com,bob@smith.net,mary@smith.net"; + + $actual = $this->groupsIntegration->expand($recipients); + + $this->assertEquals($expected, $actual); + } + public function testExpandEmpty() { $this->expectException(ServiceException::class); $recipients = "john@doe.com,namespace1:testgroup,alice@smith.net"; |