namespace OC\App;
use OCP\App\AppPathNotFoundException;
-use OC_App;
use OCP\App\IAppManager;
use OCP\App\ManagerEvent;
use OCP\IAppConfig;
* Enable an app for every user
*
* @param string $appId
- * @throws \Exception
+ * @throws AppPathNotFoundException
*/
public function enableApp($appId) {
- if(OC_App::getAppPath($appId) === false) {
- throw new \Exception("$appId can't be enabled since it is not installed.");
- }
+ // Check if app exists
+ $this->getAppPath($appId);
+
$this->installedAppsCache[$appId] = 'yes';
$this->appConfig->setValue($appId, 'enabled', 'yes');
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
* Enable an app for every user
*
* @param string $appId
+ * @throws AppPathNotFoundException
* @since 8.0.0
*/
public function enableApp($appId);
try {
$this->manager->enableApp('some_random_name_which_i_hope_is_not_an_app');
$this->assertFalse(true, 'If this line is reached the expected exception is not thrown.');
- } catch (\Exception $e) {
- // excpetion is expected
- $this->assertEquals("some_random_name_which_i_hope_is_not_an_app can't be enabled since it is not installed.", $e->getMessage());
+ } catch (AppPathNotFoundException $e) {
+ // Exception is expected
+ $this->assertEquals('Could not find path for some_random_name_which_i_hope_is_not_an_app', $e->getMessage());
}
+
$this->assertEquals('no', $this->appConfig->getValue(
'some_random_name_which_i_hope_is_not_an_app', 'enabled', 'no'
));