Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-01-24 18:52:38 +0300
committerJoas Schilling <coding@schilljs.com>2019-01-24 18:52:38 +0300
commitabd305eff5904a10218d559f596c80c08e2b9c4e (patch)
treed8c242f381c9c7009ba72870ad2889dd2a476cde /tests/lib/Activity
parent82b5828e3773f08a845a2a1d9a69247ec605f2d8 (diff)
Remove legacy activity stuff
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/Activity')
-rw-r--r--tests/lib/Activity/ManagerTest.php259
1 files changed, 22 insertions, 237 deletions
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php
index b80d6fa01b6..ba6b87ca9aa 100644
--- a/tests/lib/Activity/ManagerTest.php
+++ b/tests/lib/Activity/ManagerTest.php
@@ -1,10 +1,23 @@
<?php
/**
- * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * @copyright Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
+ * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
+ *
+ * @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/>.
*
*/
@@ -46,27 +59,18 @@ class ManagerTest extends TestCase {
$this->validator
);
- $this->assertSame([], $this->invokePrivate($this->activityManager, 'getConsumers'));
- $this->assertSame([], $this->invokePrivate($this->activityManager, 'getExtensions'));
+ $this->assertSame([], self::invokePrivate($this->activityManager, 'getConsumers'));
$this->activityManager->registerConsumer(function() {
return new NoOpConsumer();
});
- $this->activityManager->registerExtension(function() {
- return new NoOpExtension();
- });
- $this->activityManager->registerExtension(function() {
- return new SimpleExtension();
- });
- $this->assertNotEmpty($this->invokePrivate($this->activityManager, 'getConsumers'));
- $this->assertNotEmpty($this->invokePrivate($this->activityManager, 'getConsumers'));
- $this->assertNotEmpty($this->invokePrivate($this->activityManager, 'getExtensions'));
- $this->assertNotEmpty($this->invokePrivate($this->activityManager, 'getExtensions'));
+ $this->assertNotEmpty(self::invokePrivate($this->activityManager, 'getConsumers'));
+ $this->assertNotEmpty(self::invokePrivate($this->activityManager, 'getConsumers'));
}
public function testGetConsumers() {
- $consumers = $this->invokePrivate($this->activityManager, 'getConsumers');
+ $consumers = self::invokePrivate($this->activityManager, 'getConsumers');
$this->assertNotEmpty($consumers);
}
@@ -79,111 +83,7 @@ class ManagerTest extends TestCase {
return new \stdClass();
});
- $this->invokePrivate($this->activityManager, 'getConsumers');
- }
-
- public function testGetExtensions() {
- $extensions = $this->invokePrivate($this->activityManager, 'getExtensions');
-
- $this->assertNotEmpty($extensions);
- }
-
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testGetExtensionsInvalidExtension() {
- $this->activityManager->registerExtension(function() {
- return new \stdClass();
- });
-
- $this->invokePrivate($this->activityManager, 'getExtensions');
- }
-
- public function testNotificationTypes() {
- $result = $this->activityManager->getNotificationTypes('en');
- $this->assertTrue(is_array($result));
- $this->assertEquals(2, sizeof($result));
- }
-
- public function testDefaultTypes() {
- $result = $this->activityManager->getDefaultTypes('stream');
- $this->assertTrue(is_array($result));
- $this->assertEquals(1, sizeof($result));
-
- $result = $this->activityManager->getDefaultTypes('email');
- $this->assertTrue(is_array($result));
- $this->assertEquals(0, sizeof($result));
- }
-
- public function testTypeIcon() {
- $result = $this->activityManager->getTypeIcon('NT1');
- $this->assertEquals('icon-nt-one', $result);
-
- $result = $this->activityManager->getTypeIcon('NT2');
- $this->assertEquals('', $result);
- }
-
- public function testTranslate() {
- $result = $this->activityManager->translate('APP0', '', array(), false, false, 'en');
- $this->assertEquals('Stupid translation', $result);
-
- $result = $this->activityManager->translate('APP1', '', array(), false, false, 'en');
- $this->assertFalse($result);
- }
-
- public function testGetSpecialParameterList() {
- $result = $this->activityManager->getSpecialParameterList('APP0', '');
- $this->assertEquals(array(0 => 'file', 1 => 'username'), $result);
-
- $result = $this->activityManager->getSpecialParameterList('APP1', '');
- $this->assertFalse($result);
- }
-
- public function testGroupParameter() {
- $result = $this->activityManager->getGroupParameter(array());
- $this->assertEquals(5, $result);
- }
-
- public function testNavigation() {
- $result = $this->activityManager->getNavigation();
- $this->assertEquals(4, sizeof($result['apps']));
- $this->assertEquals(2, sizeof($result['top']));
- }
-
- public function testIsFilterValid() {
- $result = $this->activityManager->isFilterValid('fv01');
- $this->assertTrue($result);
-
- $result = $this->activityManager->isFilterValid('InvalidFilter');
- $this->assertFalse($result);
- }
-
- public function testFilterNotificationTypes() {
- $result = $this->activityManager->filterNotificationTypes(array('NT0', 'NT1', 'NT2', 'NT3'), 'fv01');
- $this->assertTrue(is_array($result));
- $this->assertEquals(3, sizeof($result));
-
- $result = $this->activityManager->filterNotificationTypes(array('NT0', 'NT1', 'NT2', 'NT3'), 'InvalidFilter');
- $this->assertTrue(is_array($result));
- $this->assertEquals(4, sizeof($result));
- }
-
- public function testQueryForFilter() {
- // Register twice, to test the created sql part
- $this->activityManager->registerExtension(function() {
- return new SimpleExtension();
- });
-
- $result = $this->activityManager->getQueryForFilter('fv01');
- $this->assertEquals(
- array(
- ' and ((`app` = ? and `message` like ?) or (`app` = ? and `message` like ?))',
- array('mail', 'ownCloud%', 'mail', 'ownCloud%')
- ), $result
- );
-
- $result = $this->activityManager->getQueryForFilter('InvalidFilter');
- $this->assertEquals(array(null, null), $result);
+ self::invokePrivate($this->activityManager, 'getConsumers');
}
public function getUserFromTokenThrowInvalidTokenData() {
@@ -392,121 +292,6 @@ class ManagerTest extends TestCase {
}
}
-class SimpleExtension implements \OCP\Activity\IExtension {
-
- public function getNotificationTypes($languageCode) {
- return array('NT1', 'NT2');
- }
-
- public function getDefaultTypes($method) {
- if ($method === 'stream') {
- return array('DT0');
- }
-
- return array();
- }
-
- public function getTypeIcon($type) {
- if ($type === 'NT1') {
- return 'icon-nt-one';
- }
- return '';
- }
-
- public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
- if ($app === 'APP0') {
- return "Stupid translation";
- }
-
- return false;
- }
-
- public function getSpecialParameterList($app, $text) {
- if ($app === 'APP0') {
- return array(0 => 'file', 1 => 'username');
- }
-
- return false;
- }
-
- public function getGroupParameter($activity) {
- return 5;
- }
-
- public function getNavigation() {
- return array(
- 'apps' => array('nav1', 'nav2', 'nav3', 'nav4'),
- 'top' => array('top1', 'top2')
- );
- }
-
- public function isFilterValid($filterValue) {
- if ($filterValue === 'fv01') {
- return true;
- }
-
- return false;
- }
-
- public function filterNotificationTypes($types, $filter) {
- if ($filter === 'fv01') {
- unset($types[0]);
- }
- return $types;
- }
-
- public function getQueryForFilter($filter) {
- if ($filter === 'fv01') {
- return array('`app` = ? and `message` like ?', array('mail', 'ownCloud%'));
- }
-
- return false;
- }
-}
-
-class NoOpExtension implements \OCP\Activity\IExtension {
-
- public function getNotificationTypes($languageCode) {
- return false;
- }
-
- public function getDefaultTypes($method) {
- return false;
- }
-
- public function getTypeIcon($type) {
- return false;
- }
-
- public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
- return false;
- }
-
- public function getSpecialParameterList($app, $text) {
- return false;
- }
-
- public function getGroupParameter($activity) {
- return false;
- }
-
- public function getNavigation() {
- return false;
- }
-
- public function isFilterValid($filterValue) {
- return false;
- }
-
- public function filterNotificationTypes($types, $filter) {
- return false;
- }
-
- public function getQueryForFilter($filter) {
- return false;
- }
-}
-
class NoOpConsumer implements \OCP\Activity\IConsumer {
public function receive(\OCP\Activity\IEvent $event) {