Move background job registration to install/update

This commit is contained in:
Joas Schilling 2015-09-14 09:58:00 +02:00
Родитель 624cc47f55
Коммит c4e3745677
9 изменённых файлов: 107 добавлений и 17 удалений

Просмотреть файл

@ -45,7 +45,3 @@ $c->getServer()->getNavigationManager()->add($navigationEntry);
// Personal settings for notifications and emails
\OCP\App::registerPersonal($c->getAppName(), 'personal');
// Cron job for sending emails and pruning the activity list
$c->getServer()->getJobList()->add('OCA\Activity\BackgroundJob\EmailNotification');
$c->getServer()->getJobList()->add('OCA\Activity\BackgroundJob\ExpireActivities');

Просмотреть файл

@ -15,6 +15,7 @@
<licence>AGPL</licence>
<author>Frank Karlitschek, Joas Schilling</author>
<shipped>true</shipped>
<version>2.1.3</version>
<default_enable/>
<types>
<filesystem/>

5
appinfo/install.php Normal file
Просмотреть файл

@ -0,0 +1,5 @@
<?php
// Cron job for sending emails and pruning the activity list
\OC::$server->getJobList()->add('OCA\Activity\BackgroundJob\EmailNotification');
\OC::$server->getJobList()->add('OCA\Activity\BackgroundJob\ExpireActivities');

Просмотреть файл

@ -25,3 +25,7 @@ if (version_compare($installedVersion, '1.2.2', '<')) {
$connection->executeUpdate('UPDATE `*PREFIX*activity` SET `app` = ? WHERE `type` = ?', array('files_sharing', 'shared'));
$connection->executeUpdate('UPDATE `*PREFIX*activity_mq` SET `amq_appid` = ? WHERE `amq_type` = ?', array('files_sharing', 'shared'));
}
// Cron job for sending emails and pruning the activity list
\OC::$server->getJobList()->add('OCA\Activity\BackgroundJob\EmailNotification');
\OC::$server->getJobList()->add('OCA\Activity\BackgroundJob\ExpireActivities');

Просмотреть файл

@ -1 +0,0 @@
2.1.2

Просмотреть файл

@ -20,9 +20,10 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Activity\Tests;
namespace OCA\Activity\Tests\AppInfo;
use OCA\Activity\AppInfo\Application;
use OCA\Activity\Tests\TestCase;
class ApplicationTest extends TestCase {
/** @var \OCA\Activity\AppInfo\Application */

Просмотреть файл

@ -20,7 +20,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Activity\Tests;
namespace OCA\Activity\Tests\AppInfo;
use OCA\Activity\Tests\TestCase;
class AppTest extends TestCase {
public function testNavigationEntry() {
@ -34,16 +36,6 @@ class AppTest extends TestCase {
$this->assertCount(1, $navigationManager->getAll());
}
public function testJobList() {
$jobList = \OC::$server->getJobList();
require '../appinfo/app.php';
// Test whether the background jobs got registered
$this->assertTrue($jobList->has('OCA\Activity\BackgroundJob\EmailNotification', null));
$this->assertTrue($jobList->has('OCA\Activity\BackgroundJob\ExpireActivities', null));
}
// FIXME: Uncomment once the OC_App stuff is not static anymore
// public function testPersonalPanel() {
// require '../appinfo/app.php';

Просмотреть файл

@ -0,0 +1,46 @@
<?php
/**
* ownCloud - Activity App
*
* @author Joas Schilling
* @copyright 2015 Joas Schilling nickvergessen@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Activity\Tests\AppInfo;
use OCA\Activity\Tests\TestCase;
class InstallTest extends TestCase {
public function testJobList() {
/** @var \OCP\BackgroundJob\IJobList|\PHPUnit_Framework_MockObject_MockObject $jobList */
$jobList = $this->getMockBuilder('\OCP\BackgroundJob\IJobList')
->disableOriginalConstructor()
->getMock();
// Test whether the background jobs got registered
$jobList->expects($this->at(0))
->method('add')
->with('OCA\Activity\BackgroundJob\EmailNotification');
$jobList->expects($this->at(1))
->method('add')
->with('OCA\Activity\BackgroundJob\ExpireActivities');
$this->overwriteService('JobList', $jobList);
require '../appinfo/install.php';
$this->restoreService('JobList');
}
}

Просмотреть файл

@ -0,0 +1,46 @@
<?php
/**
* ownCloud - Activity App
*
* @author Joas Schilling
* @copyright 2015 Joas Schilling nickvergessen@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Activity\Tests\AppInfo;
use OCA\Activity\Tests\TestCase;
class UpdateTest extends TestCase {
public function testJobList() {
/** @var \OCP\BackgroundJob\IJobList|\PHPUnit_Framework_MockObject_MockObject $jobList */
$jobList = $this->getMockBuilder('\OCP\BackgroundJob\IJobList')
->disableOriginalConstructor()
->getMock();
// Test whether the background jobs got registered
$jobList->expects($this->at(0))
->method('add')
->with('OCA\Activity\BackgroundJob\EmailNotification');
$jobList->expects($this->at(1))
->method('add')
->with('OCA\Activity\BackgroundJob\ExpireActivities');
$this->overwriteService('JobList', $jobList);
require '../appinfo/update.php';
$this->restoreService('JobList');
}
}