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

CommandTester.php

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