/** * Initialize the environment * * @param InputInterface $input Input * @param OutputInterface $output Output * * @return void */ protected function initialize(InputInterface $input, OutputInterface $output) { $this->console->setApplication($this->getApplication())->setInput($input)->setOutput($output); if (!$input->getOption('no-debug-file') && ($debugDir = $input->getOption('debug-dir'))) { $this->console->getFilesystem()->ensureDirectoryExists($debugDir); // keep max 20 logs $files = glob($debugDir . '/*'); while (count($files) > 19) { $this->console->getFilesystem()->remove(array_shift($files)); } $logFile = date('YmdHis'); $debugOutput = new Output(fopen(rtrim($debugDir, '\\/') . '/' . $logFile, 'w'), Output::VERBOSITY_VERY_VERBOSE, true); $this->console->setDebugOutput($debugOutput); $debugOutput->setTerminalDimensions($this->getApplication()->getTerminalDimensions()); $debugOutput->writeln($this->getHelper('formatter')->formatBlock(implode(' ', $_SERVER['argv']), 'fg=black;bg=white', true) . "\n"); } }
/** * Get a job mock * * @return \PHPUnit_Framework_MockObject_MockObject|Job */ protected function getJobMock($questionCallback = null) { $application = new Application(); if ($questionCallback) { $questionHelperMock = $this->getMock('\\Symfony\\Component\\Console\\Helper\\QuestionHelper', ['ask']); $questionHelperMock->expects($this->any())->method('ask')->willReturnCallback($questionCallback); $application->getHelperSet()->set($questionHelperMock); } $console = new Console(new Config()); $console->setInput(new ArrayInput([])); $console->setOutput(new ConsoleOutput(ConsoleOutput::VERBOSITY_QUIET)); $console->setDebugOutput(new ConsoleOutput(ConsoleOutput::VERBOSITY_QUIET)); $console->setApplication($application); $job = new \Netresearch\Kite\Job($console); $job->get('composer')->invalidatePackages(); return $job; }