summaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-11-07 15:08:56 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2016-11-08 15:58:52 +0100
commit25bcd71d029dd301321f797710d6e628540adb04 (patch)
tree54f794ce839e3d1a3714c252e95d79c6a6c20ac9 /apps/sharebymail/tests
parent3bc643ec2368a940a683e150c2ca3cc0e9df558d (diff)
downloadnextcloud-server-25bcd71d029dd301321f797710d6e628540adb04.tar.gz
nextcloud-server-25bcd71d029dd301321f797710d6e628540adb04.zip
add activity if a file was shared by mail
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/sharebymail/tests')
-rw-r--r--apps/sharebymail/tests/ActivityTest.php68
-rw-r--r--apps/sharebymail/tests/ShareByMailProviderTest.php17
2 files changed, 80 insertions, 5 deletions
diff --git a/apps/sharebymail/tests/ActivityTest.php b/apps/sharebymail/tests/ActivityTest.php
new file mode 100644
index 00000000000..9bc8c827da9
--- /dev/null
+++ b/apps/sharebymail/tests/ActivityTest.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCA\ShareByMail\Tests;
+
+
+use OCA\ShareByMail\Activity;
+
+class ActivityTest extends \Test\TestCase {
+
+ /**
+ * @var \OCA\ShareByMail\Activity
+ */
+ private $activity;
+
+ protected function setUp() {
+ parent::setUp();
+ $this->activity = new Activity(
+ $this->getMockBuilder('OCP\L10N\IFactory')
+ ->disableOriginalConstructor()
+ ->getMock(),
+ $this->getMockBuilder('OCP\Activity\IManager')
+ ->disableOriginalConstructor()
+ ->getMock()
+ );
+ }
+
+ /**
+ * @dataProvider dataTestGetSpecialParameterList
+ *
+ */
+ public function testGetSpecialParameterList($app, $text, $expected) {
+ $result = $this->activity->getSpecialParameterList($app, $text);
+ $this->assertSame($expected, $result);
+ }
+
+ public function dataTestGetSpecialParameterList() {
+ return [
+ ['sharebymail', Activity::SUBJECT_SHARED_EMAIL_SELF, [0 => 'file', 1 => 'email']],
+ ['sharebymail', Activity::SUBJECT_SHARED_EMAIL_BY, [0 => 'file', 1 => 'email', 2 => 'user']],
+ ['sharebymail', 'unknown', false],
+ ['randomApp', Activity::SUBJECT_SHARED_EMAIL_SELF, false],
+ ['randomApp', Activity::SUBJECT_SHARED_EMAIL_BY, false],
+
+ ];
+ }
+
+}
+
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php
index eedce286a03..65eded3eb7d 100644
--- a/apps/sharebymail/tests/ShareByMailProviderTest.php
+++ b/apps/sharebymail/tests/ShareByMailProviderTest.php
@@ -76,6 +76,9 @@ class ShareByMailProviderTest extends TestCase {
/** @var IShare | \PHPUnit_Framework_MockObject_MockObject */
private $share;
+ /** @var \OCP\Activity\IManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $activityManager;
+
public function setUp() {
parent::setUp();
@@ -94,6 +97,7 @@ class ShareByMailProviderTest extends TestCase {
$this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer')->getMock();
$this->urlGenerator = $this->getMockBuilder('\OCP\IUrlGenerator')->getMock();
$this->share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
+ $this->activityManager = $this->getMockBuilder('OCP\Activity\IManager')->getMock();
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
}
@@ -116,7 +120,8 @@ class ShareByMailProviderTest extends TestCase {
$this->l,
$this->logger,
$this->mailer,
- $this->urlGenerator
+ $this->urlGenerator,
+ $this->activityManager
]
);
@@ -133,7 +138,8 @@ class ShareByMailProviderTest extends TestCase {
$this->l,
$this->logger,
$this->mailer,
- $this->urlGenerator
+ $this->urlGenerator,
+ $this->activityManager
);
}
@@ -148,10 +154,11 @@ class ShareByMailProviderTest extends TestCase {
$share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share->expects($this->once())->method('getSharedWith')->willReturn('user1');
- $instance = $this->getInstance(['getSharedWith', 'createMailShare', 'getRawShare', 'createShareObject']);
+ $instance = $this->getInstance(['getSharedWith', 'createMailShare', 'getRawShare', 'createShareObject', 'createActivity']);
$instance->expects($this->once())->method('getSharedWith')->willReturn([]);
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42);
+ $instance->expects($this->once())->method('createActivity')->with($share);
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn('rawShare');
$instance->expects($this->once())->method('createShareObject')->with('rawShare')->willReturn('shareObject');
@@ -614,7 +621,7 @@ class ShareByMailProviderTest extends TestCase {
$userManager = \OC::$server->getUserManager();
$rootFolder = \OC::$server->getRootFolder();
- $provider = $this->getInstance(['sendMailNotification']);
+ $provider = $this->getInstance(['sendMailNotification', 'createActivity']);
$u1 = $userManager->createUser('testFed', md5(time()));
$u2 = $userManager->createUser('testFed2', md5(time()));
@@ -651,5 +658,5 @@ class ShareByMailProviderTest extends TestCase {
$u1->delete();
$u2->delete();
}
-
+
}