summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornoveens <noveen.sachdeva@research.iiit.ac.in>2017-03-08 15:43:47 +0530
committerMorris Jobke <hey@morrisjobke.de>2017-03-20 00:38:29 -0600
commit5481a9b84a1e3500b36583cb4c300ea0491bbdcd (patch)
treefeb825a97df3dc20cb1b243170eab4d867b32473
parent528a903a7b23ea628e6ec2fc9a221821297c0bec (diff)
downloadnextcloud-server-5481a9b84a1e3500b36583cb4c300ea0491bbdcd.tar.gz
nextcloud-server-5481a9b84a1e3500b36583cb4c300ea0491bbdcd.zip
checking if app exists in the FileStream now
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--lib/private/App/AppManager.php4
-rw-r--r--tests/lib/App/ManagerTest.php22
2 files changed, 22 insertions, 4 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 6b819ef7ac1..cc2e9203a2c 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -32,6 +32,7 @@
namespace OC\App;
use OCP\App\AppPathNotFoundException;
+use OC_App;
use OCP\App\IAppManager;
use OCP\App\ManagerEvent;
use OCP\IAppConfig;
@@ -212,6 +213,9 @@ class AppManager implements IAppManager {
* @param string $appId
*/
public function enableApp($appId) {
+ if(OC_App::getAppPath($appId) === false) {
+ throw new \Exception("$appId can't be enabled since it is not installed.");
+ }
$this->installedAppsCache[$appId] = 'yes';
$this->appConfig->setValue($appId, 'enabled', 'yes');
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
diff --git a/tests/lib/App/ManagerTest.php b/tests/lib/App/ManagerTest.php
index e38f72b3d92..79450737266 100644
--- a/tests/lib/App/ManagerTest.php
+++ b/tests/lib/App/ManagerTest.php
@@ -116,16 +116,30 @@ class ManagerTest extends TestCase {
public function testEnableApp() {
$this->expectClearCache();
- $this->manager->enableApp('test');
- $this->assertEquals('yes', $this->appConfig->getValue('test', 'enabled', 'no'));
+ // making sure "files_trashbin" is disabled
+ if ($this->manager->isEnabledForUser('files_trashbin')) {
+ $this->manager->disableApp('files_trashbin');
+ }
+ $this->manager->enableApp('files_trashbin');
+ $this->assertEquals('yes', $this->appConfig->getValue('files_trashbin', 'enabled', 'no'));
}
public function testDisableApp() {
$this->expectClearCache();
- $this->manager->disableApp('test');
- $this->assertEquals('no', $this->appConfig->getValue('test', 'enabled', 'no'));
+ $this->manager->disableApp('files_trashbin');
+ $this->assertEquals('no', $this->appConfig->getValue('files_trashbin', 'enabled', 'no'));
}
+ /**
+ * @expectedException \Exception
+ */
+ public function testNotEnableIfNotInstalled() {
+ $this->manager->enableApp('some_random_name_which_i_hope_is_not_an_app');
+ $this->assertEquals('no', $this->appConfig->getValue(
+ 'some_random_name_which_i_hope_is_not_an_app', 'enabled', 'no'
+ ));
+ }
+
public function testEnableAppForGroups() {
$groups = array(
new Group('group1', array(), null),