protected function setUp() { parent::setUp(); $this->api = $this->getMock('OC\\AppFramework\\Core\\API', array('getAppName'), array('test')); $this->api->expects($this->any())->method('getAppName')->will($this->returnValue('app')); $this->tpl = new TemplateResponse($this->api, 'home'); }
/** * Check whether sharing is enabled * @return bool */ private function isSharingEnabled() { // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app // Check whether the sharing application is enabled if (!$this->api->isAppEnabled($this->appName)) { return false; } // Check whether public sharing is enabled if ($this->appConfig->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { return false; } return true; }
/** * @NoAdminRequired */ public function deleteAddressBook() { $params = $this->request->urlParams; $response = new JSONResponse(); $backend = $this->app->getBackend($params['backend']); if (!$backend->hasAddressBookMethodFor(\OCP\PERMISSION_DELETE)) { throw new \Exception(App::$l10n->t('The "%s" backend does not support deleting address books', array($backend->name)), 501); } $addressBookInfo = $backend->getAddressBook($params['addressBookId']); if (!$addressBookInfo['permissions'] & \OCP\PERMISSION_DELETE) { throw new \Exception(App::$l10n->t('You do not have permissions to delete the "%s" address book', array($addressBookInfo['displayname'])), 403); } if (!$backend->deleteAddressBook($params['addressBookId'])) { throw new \Exception(App::$l10n->t('Error deleting address book'), 500); } \OCP\Config::setUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', time()); return $response; }
public function testIsSharingEnabledWithSharingDisabled() { $this->api->expects($this->once())->method('isAppEnabled')->with('files_sharing')->will($this->returnValue(true)); $this->appConfig->expects($this->once())->method('getValue')->with('core', 'shareapi_allow_links', 'yes')->will($this->returnValue('no')); $this->assertFalse(\Test_Helper::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled')); }