diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-02-24 15:19:15 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-02-24 15:19:15 +0100 |
commit | d43d34c93f86ffa968158e57cb03728843ec8e93 (patch) | |
tree | f9735591c6e44727a0e4116f80e183d6f89ff38e /tests | |
parent | 732541448136d41b97a7fc77f6efb23d6d893f3f (diff) | |
parent | 12fc6258854eb2e9d72a8777131e2bca71075b41 (diff) | |
download | nextcloud-server-d43d34c93f86ffa968158e57cb03728843ec8e93.tar.gz nextcloud-server-d43d34c93f86ffa968158e57cb03728843ec8e93.zip |
Merge pull request #14195 from owncloud/activity-manager-performance-improvements
Activity manager performance improvements
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/activitymanager.php | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/tests/lib/activitymanager.php b/tests/lib/activitymanager.php index 6a5af7b259b..d227c05d827 100644 --- a/tests/lib/activitymanager.php +++ b/tests/lib/activitymanager.php @@ -31,16 +31,6 @@ class Test_ActivityManager extends \Test\TestCase { $this->assertEquals(2, sizeof($result)); } - public function testFilterNotificationTypes() { - $result = $this->activityManager->filterNotificationTypes(array('NT0', 'NT1', 'NT2', 'NT3'), 'FILTER1'); - $this->assertTrue(is_array($result)); - $this->assertEquals(3, sizeof($result)); - - $result = $this->activityManager->filterNotificationTypes(array('NT0', 'NT1', 'NT2', 'NT3'), 'FILTER2'); - $this->assertTrue(is_array($result)); - $this->assertEquals(4, sizeof($result)); - } - public function testDefaultTypes() { $result = $this->activityManager->getDefaultTypes('stream'); $this->assertTrue(is_array($result)); @@ -51,6 +41,14 @@ class Test_ActivityManager extends \Test\TestCase { $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); @@ -67,14 +65,6 @@ class Test_ActivityManager extends \Test\TestCase { $this->assertFalse($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 testGroupParameter() { $result = $this->activityManager->getGroupParameter(array()); $this->assertEquals(5, $result); @@ -90,15 +80,27 @@ class Test_ActivityManager extends \Test\TestCase { $result = $this->activityManager->isFilterValid('fv01'); $this->assertTrue($result); - $result = $this->activityManager->isFilterValid('FV2'); + $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('filter1'); + + $result = $this->activityManager->getQueryForFilter('fv01'); $this->assertEquals( array( ' and ((`app` = ? and `message` like ?) or (`app` = ? and `message` like ?))', @@ -106,8 +108,8 @@ class Test_ActivityManager extends \Test\TestCase { ), $result ); - $result = $this->activityManager->isFilterValid('filter2'); - $this->assertFalse($result); + $result = $this->activityManager->getQueryForFilter('InvalidFilter'); + $this->assertEquals(array(null, null), $result); } } @@ -117,13 +119,6 @@ class SimpleExtension implements \OCP\Activity\IExtension { return array('NT1', 'NT2'); } - public function filterNotificationTypes($types, $filter) { - if ($filter === 'FILTER1') { - unset($types[0]); - } - return $types; - } - public function getDefaultTypes($method) { if ($method === 'stream') { return array('DT0'); @@ -132,6 +127,13 @@ class SimpleExtension implements \OCP\Activity\IExtension { 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"; @@ -148,13 +150,6 @@ class SimpleExtension implements \OCP\Activity\IExtension { return false; } - public function getTypeIcon($type) { - if ($type === 'NT1') { - return 'icon-nt-one'; - } - return ''; - } - public function getGroupParameter($activity) { return 5; } @@ -174,8 +169,15 @@ class SimpleExtension implements \OCP\Activity\IExtension { return false; } + public function filterNotificationTypes($types, $filter) { + if ($filter === 'fv01') { + unset($types[0]); + } + return $types; + } + public function getQueryForFilter($filter) { - if ($filter === 'filter1') { + if ($filter === 'fv01') { return array('`app` = ? and `message` like ?', array('mail', 'ownCloud%')); } @@ -189,11 +191,11 @@ class NoOpExtension implements \OCP\Activity\IExtension { return false; } - public function filterNotificationTypes($types, $filter) { + public function getDefaultTypes($method) { return false; } - public function getDefaultTypes($method) { + public function getTypeIcon($type) { return false; } @@ -205,10 +207,6 @@ class NoOpExtension implements \OCP\Activity\IExtension { return false; } - public function getTypeIcon($type) { - return false; - } - public function getGroupParameter($activity) { return false; } @@ -221,6 +219,10 @@ class NoOpExtension implements \OCP\Activity\IExtension { return false; } + public function filterNotificationTypes($types, $filter) { + return false; + } + public function getQueryForFilter($filter) { return false; } |