This commit is contained in:
Joas Schilling 2015-09-02 15:47:32 +02:00
Родитель 2143a47e27
Коммит 96edd1061b
7 изменённых файлов: 106 добавлений и 3 удалений

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

@ -36,6 +36,7 @@ use OCA\Activity\ParameterHelper;
use OCA\Activity\UserSettings;
use OCA\AnnouncementCenter\Controller\PageController;
use OCA\AnnouncementCenter\Manager;
use OCA\Notifications\Capabilities;
use OCA\Notifications\Controller\EndPointController;
use OCA\Notifications\Handler;
use OCP\AppFramework\App;
@ -64,6 +65,12 @@ class Application extends App {
$this->getCurrentUser($server->getUserSession())
);
});
$container->registerService('Capabilities', function(IContainer $c) {
return new Capabilities();
});
$container->registerCapability('Capabilities');
}
/**

48
lib/capabilities.php Normal file
Просмотреть файл

@ -0,0 +1,48 @@
<?php
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Notifications;
use OCP\Capabilities\ICapability;
/**
* Class Capabilities
*
* @package OCA\Notifications
*/
class Capabilities implements ICapability {
/**
* Return this classes capabilities
*
* @return array
*/
public function getCapabilities() {
return [
'notifications' => [
'endpoints' => [
'get',
'delete',
],
],
];
}
}

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

@ -19,7 +19,7 @@
*
*/
namespace OCA\Notifications\Tests;
namespace OCA\Notifications\Tests\AppInfo;
use OCA\Notifications\Tests\TestCase;

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

@ -19,9 +19,10 @@
*
*/
namespace OCA\Notifications\Tests;
namespace OCA\Notifications\Tests\AppInfo;
use OCA\Notifications\AppInfo\Application;
use OCA\Notifications\Tests\TestCase;
class ApplicationTest extends TestCase {
/** @var \OCA\Notifications\AppInfo\Application */
@ -44,6 +45,7 @@ class ApplicationTest extends TestCase {
public function dataContainerQuery() {
return array(
array('EndpointController', 'OCA\Notifications\Controller\EndpointController'),
array('Capabilities', 'OCA\Notifications\Capabilities'),
);
}

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

@ -19,7 +19,9 @@
*
*/
namespace OCA\Notifications\Tests;
namespace OCA\Notifications\Tests\AppInfo;
use OCA\Notifications\Tests\TestCase;
class RoutesTest extends TestCase {
public function testRoutes() {

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

@ -25,6 +25,9 @@ if (!defined('PHPUNIT_RUN')) {
require_once __DIR__.'/../../../lib/base.php';
// Temp fix for the "Path not allowed: .../tests/lib/testcase.php"
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
if(!class_exists('PHPUnit_Framework_TestCase')) {
require_once('PHPUnit/Autoload.php');
}

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

@ -0,0 +1,41 @@
<?php
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Notifications\Tests\Lib;
use OCA\Notifications\Capabilities;
use OCA\Notifications\Tests\TestCase;
class CapabilitiesTest extends TestCase {
public function testGetCapabilities() {
$capabilities = new Capabilities();
$this->assertSame([
'notifications' => [
'endpoints' => [
'get',
'delete',
],
],
], $capabilities->getCapabilities());
}
}