[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/test_tools/simpletest/ -> detached.php (source)

   1  <?php
   2      /**
   3       *    base include file for SimpleTest
   4       *    @package    SimpleTest
   5       *    @subpackage    UnitTester
   6       *    @version    $Id: detached.php 1397 2006-09-07 07:55:53Z wei $
   7       */
   8  
   9      /**#@+
  10       *    include other SimpleTest class files
  11       */
  12      require_once(dirname(__FILE__) . '/xml.php');
  13      require_once(dirname(__FILE__) . '/shell_tester.php');
  14      /**#@-*/
  15  
  16      /**
  17       *    Runs an XML formated test in a separate process.
  18       *      @package SimpleTest
  19       *      @subpackage UnitTester
  20       */
  21      class DetachedTestCase {
  22          protected $_command;
  23          protected $_dry_command;
  24          protected $_size;
  25  
  26          /**
  27           *    Sets the location of the remote test.
  28           *    @param string $command       Test script.
  29           *    @param string $dry_command   Script for dry run.
  30           *    @access public
  31           */
  32          function DetachedTestCase($command, $dry_command = false) {
  33              $this->_command = $command;
  34              $this->_dry_command = $dry_command ? $dry_command : $command;
  35              $this->_size = false;
  36          }
  37  
  38          /**
  39           *    Accessor for the test name for subclasses.
  40           *    @return string       Name of the test.
  41           *    @access public
  42           */
  43          function getLabel() {
  44              return $this->_command;
  45          }
  46  
  47          /**
  48           *    Runs the top level test for this class. Currently
  49           *    reads the data as a single chunk. I'll fix this
  50           *    once I have added iteration to the browser.
  51           *    @param SimpleReporter $reporter    Target of test results.
  52           *    @returns boolean                   True if no failures.
  53           *    @access public
  54           */
  55          function run($reporter) {
  56              $shell = new SimpleShell();
  57              $shell->execute($this->_command);
  58              $parser = $this->_createParser($reporter);
  59              if (! $parser->parse($shell->getOutput())) {
  60                  trigger_error('Cannot parse incoming XML from [' . $this->_command . ']');
  61                  return false;
  62              }
  63              return true;
  64          }
  65  
  66          /**
  67           *    Accessor for the number of subtests.
  68           *    @return integer       Number of test cases.
  69           *    @access public
  70           */
  71          function getSize() {
  72              if ($this->_size === false) {
  73                  $shell = new SimpleShell();
  74                  $shell->execute($this->_dry_command);
  75                  $reporter = new SimpleReporter();
  76                  $parser = $this->_createParser($reporter);
  77                  if (! $parser->parse($shell->getOutput())) {
  78                      trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']');
  79                      return false;
  80                  }
  81                  $this->_size = $reporter->getTestCaseCount();
  82              }
  83              return $this->_size;
  84          }
  85  
  86          /**
  87           *    Creates the XML parser.
  88           *    @param SimpleReporter $reporter    Target of test results.
  89           *    @return SimpleTestXmlListener      XML reader.
  90           *    @access protected
  91           */
  92          function &_createParser($reporter) {
  93              return new SimpleTestXmlParser($reporter);
  94          }
  95      }
  96  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7