1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace Symfony\Component\Console\Tester;
- use Symfony\Component\Console\Application;
- use Symfony\Component\Console\Input\ArrayInput;
- class ApplicationTester
- {
- use TesterTrait;
- private $application;
- private $input;
- private $statusCode;
- public function __construct(Application $application)
- {
- $this->application = $application;
- }
-
- public function run(array $input, $options = [])
- {
- $this->input = new ArrayInput($input);
- if (isset($options['interactive'])) {
- $this->input->setInteractive($options['interactive']);
- }
- $shellInteractive = getenv('SHELL_INTERACTIVE');
- if ($this->inputs) {
- $this->input->setStream(self::createStream($this->inputs));
- putenv('SHELL_INTERACTIVE=1');
- }
- $this->initOutput($options);
- $this->statusCode = $this->application->run($this->input, $this->output);
- putenv($shellInteractive ? "SHELL_INTERACTIVE=$shellInteractive" : 'SHELL_INTERACTIVE');
- return $this->statusCode;
- }
- }
|