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 / phpunit / FormatterElement.php < prev    next >
Encoding:
PHP Script  |  2007-02-13  |  3.6 KB  |  151 lines

  1. <?php
  2. /**
  3.  * $Id: FormatterElement.php 148 2007-02-13 11:15:53Z 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/system/io/PhingFile.php';
  23.  
  24. /**
  25.  * A wrapper for the implementations of PHPUnit2ResultFormatter.
  26.  *
  27.  * @author Michiel Rook <michiel.rook@gmail.com>
  28.  * @version $Id: FormatterElement.php 148 2007-02-13 11:15:53Z mrook $
  29.  * @package phing.tasks.ext.phpunit
  30.  * @since 2.1.0
  31.  */
  32. class FormatterElement
  33. {
  34.     protected $formatter = NULL;
  35.     
  36.     protected $type = "";
  37.     
  38.     protected $useFile = true;
  39.     
  40.     protected $toDir = ".";
  41.     
  42.     protected $outfile = "";
  43.  
  44.     function setType($type)
  45.     {
  46.         $this->type = $type;
  47.         
  48.         if ($this->type == "summary")
  49.         {
  50.             if (PHPUnitUtil::$installedVersion == 3)
  51.             {
  52.                 require_once 'phing/tasks/ext/phpunit/phpunit3/SummaryPHPUnit3ResultFormatter.php';
  53.                 $this->formatter = new SummaryPHPUnit3ResultFormatter();
  54.             }
  55.             else            
  56.             {
  57.                 require_once 'phing/tasks/ext/phpunit/phpunit2/SummaryPHPUnit2ResultFormatter.php';
  58.                 $this->formatter = new SummaryPHPUnit2ResultFormatter();
  59.             }
  60.         }
  61.         else
  62.         if ($this->type == "xml")
  63.         {
  64.             $destFile = new PhingFile($this->toDir, 'testsuites.xml');
  65.  
  66.             if (PHPUnitUtil::$installedVersion == 3)
  67.             {
  68.                 require_once 'phing/tasks/ext/phpunit/phpunit3/XMLPHPUnit3ResultFormatter.php';
  69.                 $this->formatter = new XMLPHPUnit3ResultFormatter();
  70.             }
  71.             else
  72.             {
  73.                 require_once 'phing/tasks/ext/phpunit/phpunit2/XMLPHPUnit2ResultFormatter.php';
  74.                 $this->formatter = new XMLPHPUnit2ResultFormatter();
  75.             }
  76.         }
  77.         else
  78.         if ($this->type == "plain")
  79.         {
  80.             if (PHPUnitUtil::$installedVersion == 3)
  81.             {
  82.                 require_once 'phing/tasks/ext/phpunit/phpunit3/PlainPHPUnit3ResultFormatter.php';
  83.                 $this->formatter = new PlainPHPUnit3ResultFormatter();
  84.             }
  85.             else
  86.             {
  87.                 require_once 'phing/tasks/ext/phpunit/phpunit2/PlainPHPUnit2ResultFormatter.php';
  88.                 $this->formatter = new PlainPHPUnit2ResultFormatter();
  89.             }
  90.         }
  91.         else
  92.         {
  93.             throw new BuildException("Formatter '" . $this->type . "' not implemented");
  94.         }
  95.     }
  96.  
  97.     function setClassName($className)
  98.     {
  99.         $classNameNoDot = Phing::import($className);
  100.  
  101.         $this->formatter = new $classNameNoDot();
  102.     }
  103.  
  104.     function setUseFile($useFile)
  105.     {
  106.         $this->useFile = $useFile;
  107.     }
  108.     
  109.     function getUseFile()
  110.     {
  111.         return $this->useFile;
  112.     }
  113.     
  114.     function setToDir($toDir)
  115.     {
  116.         $this->toDir = $toDir;
  117.     }
  118.     
  119.     function getToDir()
  120.     {
  121.         return $this->toDir;
  122.     }
  123.  
  124.     function setOutfile($outfile)
  125.     {
  126.         $this->outfile = $outfile;
  127.     }
  128.     
  129.     function getOutfile()
  130.     {
  131.         if ($this->outfile)
  132.         {
  133.             return $this->outfile;
  134.         }
  135.         else
  136.         {
  137.             return $this->formatter->getPreferredOutfile() . $this->getExtension();
  138.         }
  139.     }
  140.     
  141.     function getExtension()
  142.     {
  143.         return $this->formatter->getExtension();
  144.     }
  145.  
  146.     function getFormatter()
  147.     {
  148.         return $this->formatter;
  149.     }
  150. }
  151. ?>