/**
  * Given a big bag of install options, add installers to the collection.
  *
  * @param InstallerCollection $installers Installers will be added to this
  */
 public function addInstallers(InstallerCollection $installers)
 {
     $installers->add(new MoodleInstaller($this->execute, $this->database, $this->moodle, new MoodleConfig(), $this->branch, $this->dataDir));
     $installers->add(new PluginInstaller($this->moodle, $this->plugin, $this->pluginsDir, $this->dumper));
     $installers->add(new VendorInstaller($this->moodle, $this->plugin, $this->execute));
     if ($this->plugin->hasBehatFeatures() || $this->plugin->hasUnitTests()) {
         $installers->add(new TestSuiteInstaller($this->moodle, $this->plugin, $this->execute));
     }
 }
 public function install()
 {
     $this->getOutput()->step('Install dependencies');
     $processes = [];
     if ($this->plugin->hasUnitTests() || $this->plugin->hasBehatFeatures()) {
         $processes[] = new Process('composer install --no-interaction --prefer-dist', $this->moodle->directory, null, null, null);
     }
     $processes[] = new Process('npm install -g jshint csslint shifter@0.4.6', null, null, null, null);
     $this->execute->mustRunAll($processes);
 }
 /**
  * Install the plugin into Moodle.
  *
  * @return string
  *
  * @throws \Exception
  */
 public function installPluginIntoMoodle()
 {
     $directory = $this->moodle->getComponentInstallDirectory($this->plugin->getComponent());
     if (is_dir($directory)) {
         throw new \RuntimeException('Plugin is already installed in standard Moodle');
     }
     $this->getOutput()->info(sprintf('Copying plugin from %s to %s', $this->plugin->directory, $directory));
     // Install the plugin.
     $filesystem = new Filesystem();
     $filesystem->mirror($this->plugin->directory, $directory);
     return $directory;
 }
 /**
  * Get all the post install processes.
  *
  * @return Process[]
  */
 public function getPostInstallProcesses()
 {
     $processes = [];
     if ($this->plugin->hasBehatFeatures()) {
         $this->getOutput()->debug('Enabling Behat');
         $binDir = realpath(__DIR__ . '/../../bin');
         $processes[] = new Process(sprintf('%s/start-selenium %s', $binDir, $this->getSeleniumJarPath()));
         $processes[] = new Process(sprintf('%s/start-web-server', $binDir), $this->moodle->directory);
         $processes[] = new MoodleProcess(sprintf('%s --enable', $this->getBehatUtility()));
     }
     if ($this->plugin->hasUnitTests()) {
         $this->getOutput()->debug('Build PHPUnit config');
         $processes[] = new MoodleProcess(sprintf('%s/admin/tool/phpunit/cli/util.php --buildconfig', $this->moodle->directory));
     }
     return $processes;
 }
 public function testGetRelativeFiles()
 {
     $finder = new Finder();
     $finder->name('*.php')->sortByName();
     $plugin = new MoodlePlugin($this->pluginDir);
     $this->assertEquals(['lib.php', 'tests/lib_test.php', 'version.php'], $plugin->getRelativeFiles($finder));
 }
 protected function outputHeading(OutputInterface $output, $message)
 {
     $message = sprintf($message, $this->plugin->getComponent());
     $output->writeln(sprintf('<bg=green;fg=white;> RUN </> <fg=blue>%s</>', $message));
 }
 public function testGetRelativeFiles()
 {
     $finder = new Finder();
     $finder->name('*.php')->sortByName();
     $plugin = new MoodlePlugin($this->pluginDir);
     $expected = ['classes/math.php', 'db/access.php', 'lang/en/local_travis.php', 'lib.php', 'tests/lib_test.php', 'version.php'];
     $this->assertEquals($expected, $plugin->getRelativeFiles($finder));
 }
 /**
  * Get all files we want to add to code coverage.
  *
  * @return array
  */
 private function getCoverageFiles()
 {
     $finder = Finder::create()->name('*.php')->notName('*_test.php')->notName('version.php')->notName('settings.php')->notPath('lang')->notPath('vendor');
     $files = $this->plugin->getFiles($finder);
     return $this->removeDbFiles($this->plugin->directory . '/db', $files);
 }