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

CommandTester.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.57 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\Command\Command;
 015  use Symfony\Component\Console\Input\ArrayInput;
 016  use Symfony\Component\Console\Output\StreamOutput;
 017  use Symfony\Component\Console\Input\InputInterface;
 018  use Symfony\Component\Console\Output\OutputInterface;
 019   
 020  /**
 021   * Eases the testing of console commands.
 022   *
 023   * @author Fabien Potencier <fabien@symfony.com>
 024   */
 025  class CommandTester
 026  {
 027      private $command;
 028      private $input;
 029      private $output;
 030      private $statusCode;
 031   
 032      /**
 033       * Constructor.
 034       *
 035       * @param Command $command A Command instance to test
 036       */
 037      public function __construct(Command $command)
 038      {
 039          $this->command = $command;
 040      }
 041   
 042      /**
 043       * Executes the command.
 044       *
 045       * Available execution options:
 046       *
 047       *  * interactive: Sets the input interactive flag
 048       *  * decorated:   Sets the output decorated flag
 049       *  * verbosity:   Sets the output verbosity flag
 050       *
 051       * @param array $input   An array of command arguments and options
 052       * @param array $options An array of execution options
 053       *
 054       * @return int The command exit code
 055       */
 056      public function execute(array $input, array $options = array())
 057      {
 058          // set the command name automatically if the application requires
 059          // this argument and no command name was passed
 060          if (!isset($input['command'])
 061              && (null !== $application = $this->command->getApplication())
 062              && $application->getDefinition()->hasArgument('command')
 063          ) {
 064              $input = array_merge(array('command' => $this->command->getName()), $input);
 065          }
 066   
 067          $this->input = new ArrayInput($input);
 068          if (isset($options['interactive'])) {
 069              $this->input->setInteractive($options['interactive']);
 070          }
 071   
 072          $this->output = new StreamOutput(fopen('php://memory', 'w', false));
 073          if (isset($options['decorated'])) {
 074              $this->output->setDecorated($options['decorated']);
 075          }
 076          if (isset($options['verbosity'])) {
 077              $this->output->setVerbosity($options['verbosity']);
 078          }
 079   
 080          return $this->statusCode = $this->command->run($this->input, $this->output);
 081      }
 082   
 083      /**
 084       * Gets the display returned by the last execution of the command.
 085       *
 086       * @param bool $normalize Whether to normalize end of lines to \n or not
 087       *
 088       * @return string The display
 089       */
 090      public function getDisplay($normalize = false)
 091      {
 092          rewind($this->output->getStream());
 093   
 094          $display = stream_get_contents($this->output->getStream());
 095   
 096          if ($normalize) {
 097              $display = str_replace(PHP_EOL, "\n", $display);
 098          }
 099   
 100          return $display;
 101      }
 102   
 103      /**
 104       * Gets the input instance used by the last execution of the command.
 105       *
 106       * @return InputInterface The current input instance
 107       */
 108      public function getInput()
 109      {
 110          return $this->input;
 111      }
 112   
 113      /**
 114       * Gets the output instance used by the last execution of the command.
 115       *
 116       * @return OutputInterface The current output instance
 117       */
 118      public function getOutput()
 119      {
 120          return $this->output;
 121      }
 122   
 123      /**
 124       * Gets the status code returned by the last execution of the application.
 125       *
 126       * @return int The status code
 127       */
 128      public function getStatusCode()
 129      {
 130          return $this->statusCode;
 131      }
 132  }
 133