Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ApplicationTester.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.34 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Console\Tester;
013   
014  use Symfony\Component\Console\Application;
015  use Symfony\Component\Console\Input\ArrayInput;
016  use Symfony\Component\Console\Input\InputInterface;
017  use Symfony\Component\Console\Output\OutputInterface;
018  use Symfony\Component\Console\Output\StreamOutput;
019   
020  /**
021   * Eases the testing of console applications.
022   *
023   * When testing an application, don't forget to disable the auto exit flag:
024   *
025   *     $application = new Application();
026   *     $application->setAutoExit(false);
027   *
028   * @author Fabien Potencier <fabien@symfony.com>
029   */
030  class ApplicationTester
031  {
032      private $application;
033      private $input;
034      private $output;
035      private $statusCode;
036   
037      /**
038       * Constructor.
039       *
040       * @param Application $application An Application instance to test
041       */
042      public function __construct(Application $application)
043      {
044          $this->application = $application;
045      }
046   
047      /**
048       * Executes the application.
049       *
050       * Available options:
051       *
052       *  * interactive: Sets the input interactive flag
053       *  * decorated:   Sets the output decorated flag
054       *  * verbosity:   Sets the output verbosity flag
055       *
056       * @param array $input   An array of arguments and options
057       * @param array $options An array of options
058       *
059       * @return int The command exit code
060       */
061      public function run(array $input, $options = array())
062      {
063          $this->input = new ArrayInput($input);
064          if (isset($options['interactive'])) {
065              $this->input->setInteractive($options['interactive']);
066          }
067   
068          $this->output = new StreamOutput(fopen('php://memory', 'w', false));
069          if (isset($options['decorated'])) {
070              $this->output->setDecorated($options['decorated']);
071          }
072          if (isset($options['verbosity'])) {
073              $this->output->setVerbosity($options['verbosity']);
074          }
075   
076          return $this->statusCode = $this->application->run($this->input, $this->output);
077      }
078   
079      /**
080       * Gets the display returned by the last execution of the application.
081       *
082       * @param bool $normalize Whether to normalize end of lines to \n or not
083       *
084       * @return string The display
085       */
086      public function getDisplay($normalize = false)
087      {
088          rewind($this->output->getStream());
089   
090          $display = stream_get_contents($this->output->getStream());
091   
092          if ($normalize) {
093              $display = str_replace(PHP_EOL, "\n", $display);
094          }
095   
096          return $display;
097      }
098   
099      /**
100       * Gets the input instance used by the last execution of the application.
101       *
102       * @return InputInterface The current input instance
103       */
104      public function getInput()
105      {
106          return $this->input;
107      }
108   
109      /**
110       * Gets the output instance used by the last execution of the application.
111       *
112       * @return OutputInterface The current output instance
113       */
114      public function getOutput()
115      {
116          return $this->output;
117      }
118   
119      /**
120       * Gets the status code returned by the last execution of the application.
121       *
122       * @return int The status code
123       */
124      public function getStatusCode()
125      {
126          return $this->statusCode;
127      }
128  }
129