public function test_it_returns_a_behat_init_process()
 {
     $factory = new ProcessFactory();
     $process = $factory->create();
     static::assertInstanceOf(Process::class, $process);
     static::assertEquals('vendor/bin/behat --init', str_replace(['"', "'"], '', $process->getCommandLine()));
 }
Esempio n. 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var PackageHelper $packageHelper */
     $packageHelper = $this->getHelper('package');
     if ($packageHelper->hasPackage('behat/behat', null, $input, $output)) {
         $version = $packageHelper->getPackageVersion('behat/behat', $input, $output);
         $output->writeln(sprintf("Found %s:%s, skipping Behat installation", 'behat/behat', $version));
         return 0;
     }
     $questionHelper = $this->getHelper('question');
     /** @var RequireHelper $requireHelper */
     $requireHelper = $this->getHelper('composer require');
     $question = new Question('What package version of behat do you want to install? [latest]: ', 'latest');
     $version = $questionHelper->ask($input, $output, $question);
     $status = $requireHelper->requirePackage($output, 'behat/behat', $version == 'latest' ? '' : $version, true);
     if ($status !== 0) {
         return $status;
     }
     $process = $this->processFactory->create();
     try {
         $process->mustRun(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
         return 0;
     } catch (\Exception $e) {
         $output->write($e->getMessage());
         return $process->getExitCode();
     }
 }
Esempio n. 3
0
 protected function setUp()
 {
     parent::setUp();
     $this->inputMock = static::getMock(InputInterface::class);
     $this->outputMock = static::getMock(OutputInterface::class);
     $this->packageMock = static::getMock(PackageHelper::class);
     $this->requireMock = static::getMock(RequireHelper::class);
     $this->questionMock = Mockery::mock(QuestionHelper::class)->makePartial();
     $this->processMock = static::getMockBuilder(Process::class)->disableOriginalConstructor()->getMock();
     $this->factoryMock = static::getMockBuilder(ProcessFactory::class)->disableProxyingToOriginalMethods()->getMock();
     $this->factoryMock->expects(static::any())->method('create')->willReturn($this->processMock);
     $helperSet = new HelperSet();
     $helperSet->set($this->questionMock, 'question');
     $helperSet->set($this->packageMock, 'package');
     $helperSet->set($this->requireMock, 'composer require');
     $this->sut = new BehatCommand($this->factoryMock);
     $this->sut->setHelperSet($helperSet);
 }