home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / HTML_Progress_TestCase_setIndeterminate.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.1 KB  |  84 lines

  1. <?php
  2.  
  3. /**
  4.  * API setIndeterminate Unit tests for HTML_Progress class.
  5.  * 
  6.  * @version    $Id: HTML_Progress_TestCase_setIndeterminate.php,v 1.1 2003/11/15 18:27:11 thesaur Exp $
  7.  * @author     Laurent Laville <pear@laurent-laville.org>
  8.  * @package    HTML_Progress
  9.  */
  10.  
  11. class HTML_Progress_TestCase_setIndeterminate extends PHPUnit_TestCase
  12. {
  13.     /**
  14.      * HTML_Progress instance
  15.      *
  16.      * @var        object
  17.      */
  18.     var $progress;
  19.  
  20.     function HTML_Progress_TestCase_setIndeterminate($name)
  21.     {
  22.         $this->PHPUnit_TestCase($name);
  23.     }
  24.  
  25.     function setUp()
  26.     {
  27.         error_reporting(E_ALL);
  28.         $this->errorThrown = false;
  29.         set_error_handler(array(&$this, 'errorHandler'));
  30.  
  31.         $this->progress = new HTML_Progress();
  32.         Error_Raise::setContextGrabber($this->progress->_package, array('Error_Util', '_getFileLine'));
  33.     }
  34.  
  35.     function tearDown()
  36.     {
  37.         unset($this->progress);
  38.     }
  39.  
  40.     function _stripWhitespace($str)
  41.     {
  42.         return preg_replace('/\\s+/', '', $str);
  43.     }
  44.  
  45.     function _methodExists($name) 
  46.     {
  47.         if (in_array(strtolower($name), get_class_methods($this->progress))) {
  48.             return true;
  49.         }
  50.         $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->progress));
  51.         return false;
  52.     }
  53.  
  54.     function errorHandler($errno, $errstr, $errfile, $errline) {
  55.         //die("$errstr in $errfile at line $errline");
  56.         $this->errorThrown = true;
  57.         $this->assertTrue(false, $errstr);
  58.     }
  59.    
  60.     /**
  61.      * TestCases for method setIndeterminate.
  62.      *
  63.      */
  64.     function test_setIndeterminate_fail_no_boolean()
  65.     {
  66.         if (!$this->_methodExists('setIndeterminate')) {
  67.             return;
  68.         }
  69.         $this->progress->setIndeterminate('');
  70.     }
  71.  
  72.     function test_setIndeterminate()
  73.     {
  74.         if (!$this->_methodExists('setIndeterminate')) {
  75.             return;
  76.         }
  77.         $this->progress->setIndeterminate(true);
  78.  
  79.         $this->assertFalse($this->errorThrown, 'error thrown');
  80.     }
  81. }
  82.  
  83. ?>
  84.