protected function execute(InputInterface $input, OutputInterface $output)
 {
     $line = $input->getArgument('line');
     $file = $this->moodle->directory . '/config.php';
     $config = new MoodleConfig();
     $contents = $config->read($file);
     $contents = $config->injectLine($contents, $line);
     $config->dump($file, $contents);
     $output->writeln('<info>Updated Moodle config.php file with the following line:</info>');
     $output->writeln(['', $line, '']);
     return $this->lintFile($file, $output);
 }
 public function install()
 {
     $this->getOutput()->step('Cloning Moodle');
     $process = new Process(sprintf('git clone --depth=1 --branch %s git://github.com/moodle/moodle %s', $this->branch, $this->moodle->directory));
     $process->setTimeout(null);
     $this->execute->mustRun($process);
     // Expand the path to Moodle so all other installers use absolute path.
     $this->moodle->directory = $this->expandPath($this->moodle->directory);
     $this->getOutput()->step('Moodle assets');
     $this->getOutput()->debug('Creating Moodle data directories');
     $filesystem = new Filesystem();
     $filesystem->mkdir($this->dataDir);
     $filesystem->mkdir($this->dataDir . '/phpu_moodledata');
     $filesystem->mkdir($this->dataDir . '/behat_moodledata');
     $this->getOutput()->debug('Create Moodle database');
     $this->execute->mustRun($this->database->getCreateDatabaseCommand());
     $this->getOutput()->debug('Creating Moodle\'s config file');
     $contents = $this->config->createContents($this->database, $this->expandPath($this->dataDir));
     $this->config->dump($this->moodle->directory . '/config.php', $contents);
     $this->addEnv('MOODLE_DIR', $this->moodle->directory);
 }
 public function testDump()
 {
     $config = new MoodleConfig();
     $contents = $config->createContents(new MySQLDatabase(), '/path/to/moodledata');
     $config->dump($this->tempDir . '/config.php', $contents);
     $this->assertFileEquals(__DIR__ . '/../Fixture/example-config.php', $this->tempDir . '/config.php');
 }