]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not show an email action for contacts with emtpy email addresses 4659/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Tue, 2 May 2017 12:12:04 +0000 (14:12 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Tue, 2 May 2017 12:12:04 +0000 (14:12 +0200)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php
tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php

index d5630e6420d51789df5ccc849d0080f1e73c9b42..242fbd06a2249683bd1c54487b14ee834c5493fb 100644 (file)
@@ -52,6 +52,10 @@ class EMailProvider implements IProvider {
        public function process(IEntry $entry) {
                $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
                foreach ($entry->getEMailAddresses() as $address) {
+                       if (empty($address)) {
+                               // Skip
+                               continue;
+                       }
                        $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
                        $entry->addAction($action);
                }
index 2d82fa5d68ede153fa1ce8284b34e4e1e630d748..353c8d6f58f0ed8797cfa9f879392b8ba9135455 100644 (file)
@@ -79,4 +79,28 @@ class EMailproviderTest extends TestCase {
                $this->provider->process($entry);
        }
 
+       public function testProcessEmptyAddress() {
+               $entry = $this->createMock(IEntry::class);
+               $action = $this->createMock(ILinkAction::class);
+               $iconUrl = 'https://example.com/img/actions/icon.svg';
+               $this->urlGenerator->expects($this->once())
+                       ->method('imagePath')
+                       ->willReturn('img/actions/icon.svg');
+               $this->urlGenerator->expects($this->once())
+                       ->method('getAbsoluteURL')
+                       ->with('img/actions/icon.svg')
+                       ->willReturn($iconUrl);
+               $entry->expects($this->once())
+                       ->method('getEMailAddresses')
+                       ->willReturn([
+                               '',
+               ]);
+               $this->actionFactory->expects($this->never())
+                       ->method('newEMailAction');
+               $entry->expects($this->never())
+                       ->method('addAction');
+
+               $this->provider->process($entry);
+       }
+
 }