Testing_DocTest
[ class tree: Testing_DocTest ] [ index: Testing_DocTest ] [ all elements ]

Source for file TestSuite.php

Documentation is available at TestSuite.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * This file is part of the PEAR Testing_DocTest package.
  7.  *
  8.  * PHP version 5
  9.  *
  10.  * LICENSE: This source file is subject to the MIT license that is available
  11.  * through the world-wide-web at the following URI:
  12.  * http://opensource.org/licenses/mit-license.php
  13.  *
  14.  * @category  Testing
  15.  * @package   Testing_DocTest
  16.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  17.  * @copyright 2008 David JEAN LOUIS
  18.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  19.  * @version   CVS: $Id$
  20.  * @link      http://pear.php.net/package/Testing_DocTest
  21.  * @since     File available since release 0.1.0
  22.  * @filesource
  23.  */
  24.  
  25. /**
  26.  * This class is a container for a "suite" of test cases.
  27.  *
  28.  * @category  Testing
  29.  * @package   Testing_DocTest
  30.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  31.  * @copyright 2008 David JEAN LOUIS
  32.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  33.  * @version   Release: 0.6.0
  34.  * @link      http://pear.php.net/package/Testing_DocTest
  35.  * @since     Class available since release 0.1.0
  36.  */
  37. class Testing_DocTest_TestSuite implements IteratorAggregateCountable
  38. {
  39.     // Properties {{{
  40.  
  41.     /**
  42.      * The registry items array.
  43.      *
  44.      * @var array $_properties 
  45.      * @access private
  46.      */
  47.     private $_properties = array('name' => null);
  48.  
  49.     /**
  50.      * Array of sections.
  51.      *
  52.      * @var array $_sections 
  53.      * @access private
  54.      */
  55.     private $_testCases = array();
  56.  
  57.     // }}}
  58.     // addTestCase() {{{
  59.  
  60.     /**
  61.      * Add a test case to the suite.
  62.      *
  63.      * @param object $case a Testing_DocTest_TestCase instance.
  64.      *
  65.      * @return void 
  66.      * @access public
  67.      */
  68.     public function addTestCase(Testing_DocTest_TestCase $case)
  69.     {
  70.         $case->suite        = $this;
  71.         $this->_testCases[$case;
  72.     }
  73.  
  74.     // }}}
  75.     // __toString() {{{
  76.  
  77.     /**
  78.      * String representation of the suite.
  79.      *
  80.      * @return string 
  81.      * @access public
  82.      */
  83.     public function __toString()
  84.     {
  85.         return $this->name;
  86.     }
  87.  
  88.     // }}}
  89.     // __set() {{{
  90.  
  91.     /**
  92.      * Overloaded setter.
  93.      *
  94.      * @param string $name  name of property
  95.      * @param mixed  $value value of property
  96.      *
  97.      * @return void 
  98.      * @access public
  99.      */
  100.     public function __set($name$value)
  101.     {
  102.         $this->_properties[$name$value;
  103.     }
  104.  
  105.     // }}}
  106.     // __get() {{{
  107.  
  108.     /**
  109.      * Overloaded getter.
  110.      *
  111.      * @param string $name name of property
  112.      *
  113.      * @return mixed 
  114.      * @access public
  115.      */
  116.     public function __get($name)
  117.     {
  118.         if (isset($this->_properties[$name])) {
  119.             return $this->_properties[$name];
  120.         }
  121.         return null;
  122.     }
  123.  
  124.     // }}}
  125.     // IteratorAggregate interface implementation {{{
  126.  
  127.     /**
  128.      * Part of IteratorAggregate interface implementation.
  129.      *
  130.      * @return mixed 
  131.      * @access public
  132.      */
  133.     public function current()
  134.     {
  135.         return $this->_cases[$this->key()];
  136.     }
  137.  
  138.     /**
  139.      * Part of IteratorAggregate interface implementation.
  140.      *
  141.      * @return mixed 
  142.      * @access public
  143.      */ 
  144.     public function key()
  145.     {
  146.         return key($this->_testCases);
  147.     }
  148.  
  149.     /**
  150.      * Part of IteratorAggregate interface implementation.
  151.      *
  152.      * @return mixed 
  153.      * @access public
  154.      */ 
  155.     public function next()
  156.     {
  157.         next($this->_testCases);
  158.     }
  159.  
  160.     /**
  161.      * Part of IteratorAggregate interface implementation.
  162.      *
  163.      * @return void 
  164.      * @access public
  165.      */
  166.     public function rewind()
  167.     {
  168.         reset($this->_testCases);
  169.     }
  170.  
  171.     /**
  172.      * Part of IteratorAggregate interface implementation.
  173.      *
  174.      * @return boolean 
  175.      * @access public
  176.      */
  177.     public function valid()
  178.     {
  179.         return current($this->_testCases!== false;
  180.     }
  181.  
  182.     /**
  183.      * Part of IteratorAggregate interface implementation.
  184.      *
  185.      * @return object instance of ArrayObject
  186.      * @access public
  187.      */
  188.     public function getIterator()
  189.     {
  190.         return new ArrayObject($this->_testCases);
  191.     }
  192.  
  193.     // }}}
  194.     // Countable interface implementation {{{
  195.  
  196.     /**
  197.      * Part of Countable interface implementation.
  198.      *
  199.      * @return object instance of ArrayObject
  200.      * @access public
  201.      */
  202.     public function count()
  203.     {
  204.         return count($this->_testCases);
  205.     }
  206.  
  207.     // }}}
  208. }

Documentation generated on Mon, 11 Mar 2019 15:52:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.