[ 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/ -> simpletest.php (source)

   1  <?php
   2      /**
   3       *    Global state for SimpleTest and kicker script in future versions.
   4       *    @package    SimpleTest
   5       *    @subpackage    UnitTester
   6       *    @version    $Id: simpletest.php 1526 2006-11-28 23:34:00Z wei $
   7       */
   8  
   9      /**#@+
  10       * include SimpleTest files
  11       */
  12      if (version_compare(phpversion(), '5') >= 0) {
  13          require_once(dirname(__FILE__) . '/reflection_php5.php');
  14      } else {
  15          require_once(dirname(__FILE__) . '/reflection_php4.php');
  16      }
  17      /**#@-*/
  18  
  19      /**
  20       *    Static global directives and options. I hate this
  21       *    class. It's a mixture of reference hacks, configuration
  22       *    and previous design screw-ups that I have to maintain
  23       *    to keep backward compatibility.
  24       *      @package    SimpleTest
  25       */
  26      class SimpleTest {
  27  
  28          /**
  29           *    Reads the SimpleTest version from the release file.
  30           *    @return string        Version string.
  31           *    @static
  32           *    @access public
  33           */
  34          static function getVersion() {
  35              $content = file(dirname(__FILE__) . '/VERSION');
  36              return trim($content[0]);
  37          }
  38  
  39          /**
  40           *    Sets the name of a test case to ignore, usually
  41           *    because the class is an abstract case that should
  42           *    not be run. Once PHP4 is dropped this will disappear
  43           *    as a public method and "abstract" will rule.
  44           *    @param string $class        Add a class to ignore.
  45           *    @static
  46           *    @access public
  47           */
  48          static function ignore($class) {
  49              $registry = &SimpleTest::_getRegistry();
  50              $registry['IgnoreList'][strtolower($class)] = true;
  51          }
  52  
  53          /**
  54           *    Scans the now complete ignore list, and adds
  55           *    all parent classes to the list. If a class
  56           *    is not a runnable test case, then it's parents
  57           *    wouldn't be either. This is syntactic sugar
  58           *    to cut down on ommissions of ignore()'s or
  59           *    missing abstract declarations. This cannot
  60           *    be done whilst loading classes wiithout forcing
  61           *    a particular order on the class declarations and
  62           *    the ignore() calls. It's nice to havethe ignore()
  63           *    calls at the top of teh file.
  64           *    @param array $classes     Class names of interest.
  65           *    @static
  66           *    @access public
  67           */
  68          static function ignoreParentsIfIgnored($classes) {
  69              $registry = &SimpleTest::_getRegistry();
  70              foreach ($classes as $class) {
  71                  if (SimpleTest::isIgnored($class)) {
  72                      $reflection = new SimpleReflection($class);
  73                      if ($parent = $reflection->getParent()) {
  74                          SimpleTest::ignore($parent);
  75                      }
  76                  }
  77              }
  78          }
  79  
  80          /**
  81           *    Test to see if a test case is in the ignore
  82           *    list. Quite obviously the ignore list should
  83           *    be a separate object and will be one day.
  84           *    This method is internal to SimpleTest. Don't
  85           *    use it.
  86           *    @param string $class        Class name to test.
  87           *    @return boolean             True if should not be run.
  88           *    @access public
  89           *    @static
  90           */
  91          static function isIgnored($class) {
  92              $registry = &SimpleTest::_getRegistry();
  93              return isset($registry['IgnoreList'][strtolower($class)]);
  94          }
  95  
  96          /**
  97           *    @deprecated
  98           */
  99          function setMockBaseClass($mock_base) {
 100              $registry = &SimpleTest::_getRegistry();
 101              $registry['MockBaseClass'] = $mock_base;
 102          }
 103  
 104          /**
 105           *    @deprecated
 106           */
 107          function getMockBaseClass() {
 108              $registry = &SimpleTest::_getRegistry();
 109              return $registry['MockBaseClass'];
 110          }
 111  
 112          /**
 113           *    Sets proxy to use on all requests for when
 114           *    testing from behind a firewall. Set host
 115           *    to false to disable. This will take effect
 116           *    if there are no other proxy settings.
 117           *    @param string $proxy     Proxy host as URL.
 118           *    @param string $username  Proxy username for authentication.
 119           *    @param string $password  Proxy password for authentication.
 120           *    @access public
 121           */
 122          function useProxy($proxy, $username = false, $password = false) {
 123              $registry = &SimpleTest::_getRegistry();
 124              $registry['DefaultProxy'] = $proxy;
 125              $registry['DefaultProxyUsername'] = $username;
 126              $registry['DefaultProxyPassword'] = $password;
 127          }
 128  
 129          /**
 130           *    Accessor for default proxy host.
 131           *    @return string       Proxy URL.
 132           *    @access public
 133           */
 134          function getDefaultProxy() {
 135              $registry = &SimpleTest::_getRegistry();
 136              return $registry['DefaultProxy'];
 137          }
 138  
 139          /**
 140           *    Accessor for default proxy username.
 141           *    @return string    Proxy username for authentication.
 142           *    @access public
 143           */
 144          function getDefaultProxyUsername() {
 145              $registry = &SimpleTest::_getRegistry();
 146              return $registry['DefaultProxyUsername'];
 147          }
 148  
 149          /**
 150           *    Accessor for default proxy password.
 151           *    @return string    Proxy password for authentication.
 152           *    @access public
 153           */
 154          function getDefaultProxyPassword() {
 155              $registry = &SimpleTest::_getRegistry();
 156              return $registry['DefaultProxyPassword'];
 157          }
 158  
 159          /**
 160           *    Sets the current test case instance. This
 161           *    global instance can be used by the mock objects
 162           *    to send message to the test cases.
 163           *    @param SimpleTestCase $test        Test case to register.
 164           *    @access public
 165           *    @static
 166           */
 167          static function setCurrent($test) {
 168              $registry = &SimpleTest::_getRegistry();
 169              $registry['CurrentTestCase'] = $test;
 170          }
 171  
 172          /**
 173           *    Accessor for current test instance.
 174           *    @return SimpleTEstCase        Currently running test.
 175           *    @access public
 176           *    @static
 177           */
 178          static function &getCurrent() {
 179              $registry = &SimpleTest::_getRegistry();
 180              return $registry['CurrentTestCase'];
 181          }
 182  
 183          /**
 184           *    Accessor for global registry of options.
 185           *    @return hash           All stored values.
 186           *    @access private
 187           *    @static
 188           */
 189          static function &_getRegistry() {
 190              static $registry = false;
 191              if (! $registry) {
 192                  $registry = SimpleTest::_getDefaults();
 193              }
 194              return $registry;
 195          }
 196  
 197          /**
 198           *    Constant default values.
 199           *    @return hash       All registry defaults.
 200           *    @access private
 201           *    @static
 202           */
 203          static function _getDefaults() {
 204              return array(
 205                      'StubBaseClass' => 'SimpleStub',
 206                      'MockBaseClass' => 'SimpleMock',
 207                      'IgnoreList' => array(),
 208                      'DefaultProxy' => false,
 209                      'DefaultProxyUsername' => false,
 210                      'DefaultProxyPassword' => false);
 211          }
 212      }
 213  
 214      /**
 215       *    @deprecated
 216       */
 217      class SimpleTestOptions extends SimpleTest {
 218  
 219          /**
 220           *    @deprecated
 221           */
 222          static function getVersion() {
 223              return Simpletest::getVersion();
 224          }
 225  
 226          /**
 227           *    @deprecated
 228           */
 229          static function ignore($class) {
 230              return Simpletest::ignore($class);
 231          }
 232  
 233          /**
 234           *    @deprecated
 235           */
 236          static function isIgnored($class) {
 237              return Simpletest::isIgnored($class);
 238          }
 239  
 240          /**
 241           *    @deprecated
 242           */
 243          function setMockBaseClass($mock_base) {
 244              return Simpletest::setMockBaseClass($mock_base);
 245          }
 246  
 247          /**
 248           *    @deprecated
 249           */
 250          function getMockBaseClass() {
 251              return Simpletest::getMockBaseClass();
 252          }
 253  
 254          /**
 255           *    @deprecated
 256           */
 257          function useProxy($proxy, $username = false, $password = false) {
 258              return Simpletest::useProxy($proxy, $username, $password);
 259          }
 260  
 261          /**
 262           *    @deprecated
 263           */
 264          function getDefaultProxy() {
 265              return Simpletest::getDefaultProxy();
 266          }
 267  
 268          /**
 269           *    @deprecated
 270           */
 271          function getDefaultProxyUsername() {
 272              return Simpletest::getDefaultProxyUsername();
 273          }
 274  
 275          /**
 276           *    @deprecated
 277           */
 278          function getDefaultProxyPassword() {
 279              return Simpletest::getDefaultProxyPassword();
 280          }
 281      }
 282  ?>


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