home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / phing / tasks / ext / phpunit2 / FormatterElement.php < prev    next >
Encoding:
PHP Script  |  2007-12-21  |  2.7 KB  |  120 lines

  1. <?php
  2. /**
  3.  * $Id: FormatterElement.php 82 2006-07-07 18:15:35Z mrook $
  4.  *
  5.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * This software consists of voluntary contributions made by many individuals
  18.  * and is licensed under the LGPL. For more information please see
  19.  * <http://phing.info>.
  20.  */
  21.  
  22. require_once 'phing/tasks/ext/phpunit2/XMLPHPUnit2ResultFormatter.php';
  23. require_once 'phing/tasks/ext/phpunit2/PlainPHPUnit2ResultFormatter.php';
  24. require_once 'phing/system/io/PhingFile.php';
  25.  
  26. /**
  27.  * A wrapper for the implementations of PHPUnit2ResultFormatter.
  28.  *
  29.  * @author Michiel Rook <michiel.rook@gmail.com>
  30.  * @version $Id: FormatterElement.php 82 2006-07-07 18:15:35Z mrook $
  31.  * @package phing.tasks.ext.phpunit2
  32.  * @since 2.1.0
  33.  */
  34. class FormatterElement
  35. {
  36.     protected $formatter = NULL;
  37.     
  38.     protected $type = "";
  39.     
  40.     protected $useFile = true;
  41.     
  42.     protected $toDir = ".";
  43.     
  44.     protected $outfile = "";
  45.  
  46.     function setType($type)
  47.     {
  48.         $this->type = $type;
  49.  
  50.         if ($this->type == "xml")
  51.         {
  52.             $destFile = new PhingFile($this->toDir, 'testsuites.xml');
  53.             $this->formatter = new XMLPHPUnit2ResultFormatter();
  54.         }
  55.         else
  56.         if ($this->type == "plain")
  57.         {
  58.             $this->formatter = new PlainPHPUnit2ResultFormatter();
  59.         }
  60.         else
  61.         {
  62.             throw new BuildException("Formatter '" . $this->type . "' not implemented");
  63.         }
  64.     }
  65.  
  66.     function setClassName($className)
  67.     {
  68.         $classNameNoDot = Phing::import($className);
  69.  
  70.         $this->formatter = new $classNameNoDot();
  71.     }
  72.  
  73.     function setUseFile($useFile)
  74.     {
  75.         $this->useFile = $useFile;
  76.     }
  77.     
  78.     function getUseFile()
  79.     {
  80.         return $this->useFile;
  81.     }
  82.     
  83.     function setToDir($toDir)
  84.     {
  85.         $this->toDir = $toDir;
  86.     }
  87.     
  88.     function getToDir()
  89.     {
  90.         return $this->toDir;
  91.     }
  92.  
  93.     function setOutfile($outfile)
  94.     {
  95.         $this->outfile = $outfile;
  96.     }
  97.     
  98.     function getOutfile()
  99.     {
  100.         if ($this->outfile)
  101.         {
  102.             return $this->outfile;
  103.         }
  104.         else
  105.         {
  106.             return $this->formatter->getPreferredOutfile() . $this->getExtension();
  107.         }
  108.     }
  109.     
  110.     function getExtension()
  111.     {
  112.         return $this->formatter->getExtension();
  113.     }
  114.  
  115.     function getFormatter()
  116.     {
  117.         return $this->formatter;
  118.     }
  119. }
  120. ?>