private function createDatabase()
 {
     $command = new CreateDatabaseDoctrineCommand();
     $command->setContainer($this->getContainer());
     $code = $command->run(new ArrayInput(array()), new NullOutput());
     if ($code !== 0) {
         throw new \Exception('Database cannot be created (existing database must be dropped first)');
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>%s - Installing the platform...</comment>', date('H:i:s')));
     $databaseCreator = new CreateDatabaseDoctrineCommand();
     $databaseCreator->setContainer($this->getContainer());
     $databaseCreator->run(new ArrayInput(array()), $output);
     $verbosityLevelMap = array(LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL, LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL, LogLevel::DEBUG => OutputInterface::VERBOSITY_NORMAL);
     $consoleLogger = new ConsoleLogger($output, $verbosityLevelMap);
     /** @var \Claroline\CoreBundle\Library\Installation\PlatformInstaller $installer */
     $installer = $this->getContainer()->get('claroline.installation.platform_installer');
     $installer->setOutput($output);
     $installer->setLogger($consoleLogger);
     $installer->installFromKernel($input->getOption('with-optional-fixtures'));
     $output->writeln(sprintf('<comment>%s - Platform installed.</comment>', date('H:i:s')));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf('<comment>%s - Updating the platform...</comment>', date('H:i:s')));
     $databaseCreator = new CreateDatabaseDoctrineCommand();
     $databaseCreator->setContainer($this->getContainer());
     $databaseCreator->run(new ArrayInput(array()), $output);
     $verbosityLevelMap = array(LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL, LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL, LogLevel::DEBUG => OutputInterface::VERBOSITY_NORMAL);
     $consoleLogger = new ConsoleLogger($output, $verbosityLevelMap);
     /** @var \Claroline\CoreBundle\Library\Installation\PlatformInstaller $installer */
     $installer = $this->getContainer()->get('claroline.installation.platform_installer');
     $installer->setOutput($output);
     $installer->setLogger($consoleLogger);
     $installer->updateFromComposerInfo();
     /** @var \Claroline\CoreBundle\Library\Installation\Refresher $refresher */
     $refresher = $this->getContainer()->get('claroline.installation.refresher');
     $refresher->dumpAssets($this->getContainer()->getParameter('kernel.environment'));
     MaintenanceHandler::disableMaintenance();
     $output->writeln(sprintf('<comment>%s - Platform updated.</comment>', date('H:i:s')));
 }
Example #4
0
 private function createDatabaseIfNotExists()
 {
     try {
         $this->log('Checking database connection...');
         $cn = $this->container->get('doctrine.dbal.default_connection');
         // todo: implement a more sophisticated way to test connection, as the
         // following query works mainly in MySQL, PostgreSQL and MS-Server
         // see http://stackoverflow.com/questions/3668506/efficient-sql-test-query-or-validation-query-that-will-work-across-all-or-most
         $cn->query('SELECT 1');
     } catch (\Exception $ex) {
         $this->log('Unable to connect to database: trying to create database...');
         $command = new CreateDatabaseDoctrineCommand();
         $command->setContainer($this->container);
         $code = $command->run(new ArrayInput(array()), $this->output ?: new NullOutput());
         if ($code !== 0) {
             throw new \Exception('Database cannot be created : check that the parameters you provided ' . 'are correct and/or that you have sufficient permissions.');
         }
     }
 }
Example #5
0
 public function testRunInstallCommandChooseNothing()
 {
     $application = new Application($this->getClient()->getKernel());
     $application->add(new InstallCommand());
     $application->add(new DropDatabaseDoctrineCommand());
     $application->add(new CreateDatabaseDoctrineCommand());
     // drop database first, so the install command won't ask to reset things
     $command = new DropDatabaseDoctrineCommand();
     $command->setApplication($application);
     $command->run(new ArrayInput(['command' => 'doctrine:database:drop', '--force' => true]), new NullOutput());
     $this->getClient()->getContainer()->get('doctrine')->getConnection()->close();
     $command = new CreateDatabaseDoctrineCommand();
     $command->setApplication($application);
     $command->run(new ArrayInput(['command' => 'doctrine:database:create', '--env' => 'test']), new NullOutput());
     $command = $application->find('wallabag:install');
     // We mock the QuestionHelper
     $question = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\QuestionHelper')->disableOriginalConstructor()->getMock();
     $question->expects($this->exactly(2))->method('ask')->will($this->onConsecutiveCalls(false, false));
     // We override the standard helper with our mock
     $command->getHelperSet()->set($question, 'question');
     $tester = new CommandTester($command);
     $tester->execute(['command' => $command->getName()]);
     $this->assertContains('Checking system requirements.', $tester->getDisplay());
     $this->assertContains('Setting up database.', $tester->getDisplay());
     $this->assertContains('Administration setup.', $tester->getDisplay());
     $this->assertContains('Config setup.', $tester->getDisplay());
     $this->assertContains('Creating schema', $tester->getDisplay());
 }