Ejemplo n.º 1
0
 public function test_behat_command_added_to_config_if_phpunit_is_installed()
 {
     $this->packageHelper->method('hasPackage')->willReturnMap([['behat/behat', null, $this->input, $this->output, true]]);
     $this->questionHelper->method('confirmRunBehat')->willReturn(true);
     $actual = $this->sut->createConfig($this->input, $this->output);
     self::assertContains('vendor/bin/behat', $actual->getScript());
 }
Ejemplo n.º 2
0
 public function test_do_not_write_file_when_file_already_exists_and_user_cancels_overwrite()
 {
     file_put_contents($this->configPath, $expected = 'StuffAndThings');
     $this->questionHelper->method('confirmOverwriteFile')->willReturn(false);
     $this->configBuilder->method('createConfig')->willReturn(new Config());
     $actual = $this->sut->run($this->input, $this->output);
     self::assertEquals(0, $actual);
     self::assertFileExists($this->configPath);
     self::assertEquals($expected, file_get_contents($this->configPath));
 }
Ejemplo n.º 3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null
  * @throws \Symfony\Component\Console\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Console\Exception\RuntimeException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var PathHelper $pathHelper */
     $pathHelper = $this->getHelper('path');
     $configPath = $pathHelper->getPath('.travis.yml');
     if (file_exists($configPath)) {
         $shouldOverwrite = $this->questionHelper->confirmOverwriteFile($input, $output, $configPath);
         if (!$shouldOverwrite) {
             return 0;
         }
     }
     $config = $this->configBuilder->createConfig($input, $output);
     $this->configWriter->toYmlFile($config, $configPath);
     return 0;
 }
 public function test_loop_until_valid_answer_on_which_builds_can_fail()
 {
     $this->questionHelper->method('ask')->willReturnOnConsecutiveCalls('6.0', 'asdf', '7.0', null);
     $actual = $this->sut->askWhichBuildsAreAllowedToFail($this->input, $this->output, ['7.0', '5.6', '5.5']);
     self::assertInternalType('array', $actual);
     self::assertContains('7.0', $actual);
 }
Ejemplo n.º 5
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return Config
  * @throws \Symfony\Component\Console\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Console\Exception\RuntimeException
  */
 public function createConfig(InputInterface $input, OutputInterface $output)
 {
     $config = new Config('php');
     // Configure the PHP versions to build.
     $versions = $this->questionHelper->askWhichPhpVersionsToBuild($input, $output, self::$allowedPhpVersions);
     if (is_array($versions)) {
         $config->setPhp($versions);
         // Configure the builds that are allowed to fail for particular PHP versions.
         $allowedToFail = $this->questionHelper->askWhichBuildsAreAllowedToFail($input, $output, $versions);
         if (is_array($allowedToFail)) {
             $config->getMatrix()->setAllowFailures('php', $allowedToFail);
         }
     }
     // Configure installation of dependencies via Composer, and Composer self-update.
     $composerInstall = $this->questionHelper->confirmComposerInstall($input, $output);
     if ($composerInstall) {
         $composerSelfUpdate = $this->questionHelper->confirmComposerSelfUpdate($input, $output);
         if ($composerSelfUpdate) {
             $config->addBeforeScript('composer self-update');
         }
         $config->addBeforeScript('composer install --no-interaction');
     }
     // Configure execution of PHPUnit.
     if ($this->packageHelper->hasPackage('phpunit/phpunit', null, $input, $output) && $this->questionHelper->confirmRunPhpUnit($input, $output)) {
         // TODO Get bin filename from package helper.
         $config->addScript('vendor/bin/phpunit --coverage-text');
     }
     // Configure execution of Behat.
     if ($this->packageHelper->hasPackage('behat/behat', null, $input, $output) && $this->questionHelper->confirmRunBehat($input, $output)) {
         // TODO Get bin filename from package helper.
         $config->addScript('vendor/bin/behat');
     }
     return $config;
 }