checking if app exists in the FileStream now
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
528a903a7b
commit
5481a9b84a
|
@ -32,6 +32,7 @@
|
||||||
namespace OC\App;
|
namespace OC\App;
|
||||||
|
|
||||||
use OCP\App\AppPathNotFoundException;
|
use OCP\App\AppPathNotFoundException;
|
||||||
|
use OC_App;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\App\ManagerEvent;
|
use OCP\App\ManagerEvent;
|
||||||
use OCP\IAppConfig;
|
use OCP\IAppConfig;
|
||||||
|
@ -212,6 +213,9 @@ class AppManager implements IAppManager {
|
||||||
* @param string $appId
|
* @param string $appId
|
||||||
*/
|
*/
|
||||||
public function enableApp($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->installedAppsCache[$appId] = 'yes';
|
||||||
$this->appConfig->setValue($appId, 'enabled', 'yes');
|
$this->appConfig->setValue($appId, 'enabled', 'yes');
|
||||||
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
|
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
|
||||||
|
|
|
@ -116,16 +116,30 @@ class ManagerTest extends TestCase {
|
||||||
|
|
||||||
public function testEnableApp() {
|
public function testEnableApp() {
|
||||||
$this->expectClearCache();
|
$this->expectClearCache();
|
||||||
$this->manager->enableApp('test');
|
// making sure "files_trashbin" is disabled
|
||||||
$this->assertEquals('yes', $this->appConfig->getValue('test', 'enabled', 'no'));
|
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() {
|
public function testDisableApp() {
|
||||||
$this->expectClearCache();
|
$this->expectClearCache();
|
||||||
$this->manager->disableApp('test');
|
$this->manager->disableApp('files_trashbin');
|
||||||
$this->assertEquals('no', $this->appConfig->getValue('test', 'enabled', 'no'));
|
$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() {
|
public function testEnableAppForGroups() {
|
||||||
$groups = array(
|
$groups = array(
|
||||||
new Group('group1', array(), null),
|
new Group('group1', array(), null),
|
||||||
|
|
Loading…
Reference in New Issue