public function testStartMigrationSuccessful()
 {
     // we need to be able to autoload the class we're mocking
     \OC_App::registerAutoloading('encryption', \OC_App::getAppPath('encryption'));
     $migration = $this->getMockBuilder('\\OCA\\Encryption\\Migration')->disableOriginalConstructor()->getMock();
     $this->encryptionController->expects($this->once())->method('getMigration')->with($this->config, $this->view, $this->connection, $this->logger)->will($this->returnValue($migration));
     $migration->expects($this->once())->method('reorganizeSystemFolderStructure');
     $migration->expects($this->once())->method('updateDB');
     $backend = $this->getMockBuilder('\\OCP\\UserInterface')->getMock();
     $this->userManager->expects($this->once())->method('getBackends')->will($this->returnValue([$backend]));
     $backend->expects($this->once())->method('getUsers')->will($this->returnValue(['User 1', 'User 2']));
     $migration->expects($this->exactly(2))->method('reorganizeFolderStructureForUser')->withConsecutive(['User 1'], ['User 2']);
     $migration->expects($this->once())->method('finalCleanUp');
     $expected = ['data' => ['message' => 'Migration Completed'], 'status' => 'success'];
     $this->assertSame($expected, $this->encryptionController->startMigration());
 }
예제 #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \Exception
  */
 public function loadCommands(InputInterface $input, OutputInterface $output)
 {
     // $application is required to be defined in the register_command scripts
     $application = $this->application;
     $inputDefinition = $application->getDefinition();
     $inputDefinition->addOption(new InputOption('no-warnings', null, InputOption::VALUE_NONE, 'Skip global warnings, show command output only', null));
     try {
         $input->bind($inputDefinition);
     } catch (\RuntimeException $e) {
         //expected if there are extra options
     }
     if ($input->getOption('no-warnings')) {
         $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
     }
     require_once __DIR__ . '/../../../core/register_command.php';
     if ($this->config->getSystemValue('installed', false)) {
         if (\OCP\Util::needUpgrade()) {
             $output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
             $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
         } elseif ($this->config->getSystemValue('maintenance', false)) {
             $output->writeln("ownCloud is in maintenance mode - no app have been loaded");
         } else {
             OC_App::loadApps();
             foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
                 $appPath = \OC_App::getAppPath($app);
                 if ($appPath === false) {
                     continue;
                 }
                 \OC_App::registerAutoloading($app, $appPath);
                 $file = $appPath . '/appinfo/register_command.php';
                 if (file_exists($file)) {
                     require $file;
                 }
             }
         }
     } else {
         $output->writeln("ownCloud is not installed - only a limited number of commands are available");
     }
     $input = new ArgvInput();
     if ($input->getFirstArgument() !== 'check') {
         $errors = \OC_Util::checkServer(\OC::$server->getConfig());
         if (!empty($errors)) {
             foreach ($errors as $error) {
                 $output->writeln((string) $error['error']);
                 $output->writeln((string) $error['hint']);
                 $output->writeln('');
             }
             throw new \Exception("Environment not properly prepared.");
         }
     }
 }
예제 #3
0
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @return integer
  */
 public static function installShippedApp($app)
 {
     //install the database
     $appPath = OC_App::getAppPath($app);
     if (is_file("{$appPath}/appinfo/database.xml")) {
         OC_DB::createDbFromStructure("{$appPath}/appinfo/database.xml");
     }
     //run appinfo/install.php
     \OC_App::registerAutoloading($app, $appPath);
     self::includeAppScript("{$appPath}/appinfo/install.php");
     $info = OC_App::getAppInfo($app);
     if (is_null($info)) {
         return false;
     }
     \OC_App::setupBackgroundJobs($info['background-jobs']);
     OC_App::executeRepairSteps($app, $info['repair-steps']['install']);
     $config = \OC::$server->getConfig();
     $config->setAppValue($app, 'installed_version', OC_App::getAppVersion($app));
     if (array_key_exists('ocsid', $info)) {
         $config->setAppValue($app, 'ocsid', $info['ocsid']);
     }
     //set remote/public handlers
     foreach ($info['remote'] as $name => $path) {
         $config->setAppValue('core', 'remote_' . $name, $app . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         $config->setAppValue('core', 'public_' . $name, $app . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info['id'];
 }