[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /** 3 * $Id: CoverageReportTransformer.php 3076 2006-12-18 08:52:12Z fabien $ 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/Task.php'; 23 require_once 'phing/system/io/PhingFile.php'; 24 require_once 'phing/system/io/FileWriter.php'; 25 require_once 'phing/util/ExtendedFileStream.php'; 26 27 /** 28 * Transform a Phing/Xdebug code coverage xml report. 29 * The default transformation generates an html report in framed style. 30 * 31 * @author Michiel Rook <michiel.rook@gmail.com> 32 * @version $Id: CoverageReportTransformer.php 3076 2006-12-18 08:52:12Z fabien $ 33 * @package phing.tasks.ext.coverage 34 * @since 2.1.0 35 */ 36 class CoverageReportTransformer 37 { 38 private $task = NULL; 39 private $styleDir = ""; 40 private $toDir = ""; 41 private $document = NULL; 42 43 function __construct(Task $task) 44 { 45 $this->task = $task; 46 } 47 48 function setStyleDir($styleDir) 49 { 50 $this->styleDir = $styleDir; 51 } 52 53 function setToDir($toDir) 54 { 55 $this->toDir = $toDir; 56 } 57 58 function setXmlDocument($document) 59 { 60 $this->document = $document; 61 } 62 63 function transform() 64 { 65 $dir = new PhingFile($this->toDir); 66 67 if (!$dir->exists()) 68 { 69 throw new BuildException("Directory '" . $this->toDir . "' does not exist"); 70 } 71 72 $xslfile = $this->getStyleSheet(); 73 74 $xsl = new DOMDocument(); 75 $xsl->load($xslfile->getAbsolutePath()); 76 77 $proc = new XSLTProcessor(); 78 $proc->importStyleSheet($xsl); 79 80 ExtendedFileStream::registerStream(); 81 82 // no output for the framed report 83 // it's all done by extension... 84 $proc->setParameter('', 'output.dir', $dir->getAbsolutePath()); 85 $proc->transformToXML($this->document); 86 } 87 88 private function getStyleSheet() 89 { 90 $xslname = "coverage-frames.xsl"; 91 92 if ($this->styleDir) 93 { 94 $file = new PhingFile($this->styleDir, $xslname); 95 } 96 else 97 { 98 $path = Phing::getResourcePath("phing/etc/$xslname"); 99 100 if ($path === NULL) 101 { 102 $path = Phing::getResourcePath("etc/$xslname"); 103 104 if ($path === NULL) 105 { 106 throw new BuildException("Could not find $xslname in resource path"); 107 } 108 } 109 110 $file = new PhingFile($path); 111 } 112 113 if (!$file->exists()) 114 { 115 throw new BuildException("Could not find file " . $file->getPath()); 116 } 117 118 return $file; 119 } 120 } 121 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |