TYPO3  7.6
ApplicationTester.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Console\Tester;
13 
19 
31 {
32  private $application;
33  private $input;
34  private $output;
35  private $statusCode;
36 
43  {
44  $this->application = $application;
45  }
46 
61  public function run(array $input, $options = array())
62  {
63  $this->input = new ArrayInput($input);
64  if (isset($options['interactive'])) {
65  $this->input->setInteractive($options['interactive']);
66  }
67 
68  $this->output = new StreamOutput(fopen('php://memory', 'w', false));
69  if (isset($options['decorated'])) {
70  $this->output->setDecorated($options['decorated']);
71  }
72  if (isset($options['verbosity'])) {
73  $this->output->setVerbosity($options['verbosity']);
74  }
75 
76  return $this->statusCode = $this->application->run($this->input, $this->output);
77  }
78 
86  public function getDisplay($normalize = false)
87  {
88  rewind($this->output->getStream());
89 
90  $display = stream_get_contents($this->output->getStream());
91 
92  if ($normalize) {
93  $display = str_replace(PHP_EOL, "\n", $display);
94  }
95 
96  return $display;
97  }
98 
104  public function getInput()
105  {
106  return $this->input;
107  }
108 
114  public function getOutput()
115  {
116  return $this->output;
117  }
118 
124  public function getStatusCode()
125  {
126  return $this->statusCode;
127  }
128 }