Esempio n. 1
0
 public function test_it_will_not_try_to_initialize_behat_if_installation_fails()
 {
     $this->packageMock->expects(static::any())->method('hasPackage')->with('behat/behat', null, $this->inputMock, $this->outputMock)->willReturn(false);
     $this->requireMock->expects(static::any())->method('requirePackage')->willReturn($status = 7);
     $this->processMock->expects(static::never())->method('mustRun');
     static::assertEquals($status, $this->sut->run($this->inputMock, $this->outputMock));
 }
 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());
 }
Esempio n. 3
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;
 }
 public function test_it_will_install_code_sniffer_with_specified_version()
 {
     $this->packageMock->expects(static::any())->method('hasPackage')->with(CodeSnifferCommand::PACKAGE_NAME, null, $this->inputMock, $this->outputMock)->willReturn(false);
     $this->questionMock->shouldReceive('ask')->once()->with($this->inputMock, $this->outputMock, Mockery::on(function (Question $question) {
         if (strpos($question->getQuestion(), 'What package version of CodeSniffer do you want to install? [latest]: ') !== false) {
             return true;
         }
         return false;
     }))->andReturn($version = 'v1.0');
     $this->requireMock->expects(static::once())->method('requirePackage')->with($this->outputMock, CodeSnifferCommand::PACKAGE_NAME, $version, true)->willReturn(0);
     static::assertEquals(0, $this->sut->run($this->inputMock, $this->outputMock));
 }
 public function test_it_will_not_install_phpunit_if_already_present()
 {
     $this->packageMock->expects(static::any())->method('hasPackage')->with('phpunit/phpunit', null, $this->inputMock, $this->outputMock)->willReturn(true);
     $this->requireMock->expects(static::never())->method('requirePackage');
     static::assertEquals(0, $this->sut->run($this->inputMock, $this->outputMock));
 }