Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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:58 - Dateigröße: 3.09 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   
036      /**
037       * Constructor.
038       *
039       * @param Application $application An Application instance to test.
040       */
041      public function __construct(Application $application)
042      {
043          $this->application = $application;
044      }
045   
046      /**
047       * Executes the application.
048       *
049       * Available options:
050       *
051       *  * interactive: Sets the input interactive flag
052       *  * decorated:   Sets the output decorated flag
053       *  * verbosity:   Sets the output verbosity flag
054       *
055       * @param array $input   An array of arguments and options
056       * @param array $options An array of options
057       *
058       * @return int     The command exit code
059       */
060      public function run(array $input, $options = array())
061      {
062          $this->input = new ArrayInput($input);
063          if (isset($options['interactive'])) {
064              $this->input->setInteractive($options['interactive']);
065          }
066   
067          $this->output = new StreamOutput(fopen('php://memory', 'w', false));
068          if (isset($options['decorated'])) {
069              $this->output->setDecorated($options['decorated']);
070          }
071          if (isset($options['verbosity'])) {
072              $this->output->setVerbosity($options['verbosity']);
073          }
074   
075          return $this->application->run($this->input, $this->output);
076      }
077   
078      /**
079       * Gets the display returned by the last execution of the application.
080       *
081       * @param bool    $normalize Whether to normalize end of lines to \n or not
082       *
083       * @return string The display
084       */
085      public function getDisplay($normalize = false)
086      {
087          rewind($this->output->getStream());
088   
089          $display = stream_get_contents($this->output->getStream());
090   
091          if ($normalize) {
092              $display = str_replace(PHP_EOL, "\n", $display);
093          }
094   
095          return $display;
096      }
097   
098      /**
099       * Gets the input instance used by the last execution of the application.
100       *
101       * @return InputInterface The current input instance
102       */
103      public function getInput()
104      {
105          return $this->input;
106      }
107   
108      /**
109       * Gets the output instance used by the last execution of the application.
110       *
111       * @return OutputInterface The current output instance
112       */
113      public function getOutput()
114      {
115          return $this->output;
116      }
117  }
118