/** * @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_confirm_overwrite_config_file() { $this->questionHelper->method('ask')->willReturn($expected = 'no'); $actual = $this->sut->confirmOverwriteFile($this->input, $this->output, '.travis.yml'); self::assertEquals($expected, $actual); }