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

  1. <?php
  2.  
  3. /**
  4.  * API setCellAttributes Unit tests for HTML_Progress_UI class.
  5.  * 
  6.  * @version    $Id: HTML_Progress_TestCase_UI_setCellAttributes.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_UI_setCellAttributes extends PHPUnit_TestCase
  12. {
  13.     /**
  14.      * HTML_Progress_UI instance
  15.      *
  16.      * @var        object
  17.      */
  18.     var $ui;
  19.  
  20.     function HTML_Progress_TestCase_UI_setCellAttributes($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->ui = new HTML_Progress_UI();
  32.         Error_Raise::setContextGrabber($this->ui->_package, array('Error_Util', '_getFileLine'));
  33.     }
  34.  
  35.     function tearDown()
  36.     {
  37.         unset($this->ui);
  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->ui))) {
  48.             return true;
  49.         }
  50.         $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->ui));
  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 setCellAttributes.
  62.      *
  63.      */
  64.     function test_setCellAttributes_fail_no_integer()
  65.     {
  66.         if (!$this->_methodExists('setCellAttributes')) {
  67.             return;
  68.         }
  69.         $this->ui->setCellAttributes('','');
  70.     }
  71.  
  72.     function test_setCellAttributes_fail_no_positive()
  73.     {
  74.         if (!$this->_methodExists('setCellAttributes')) {
  75.             return;
  76.         }
  77.         $this->ui->setCellAttributes('',-1);
  78.     }
  79.  
  80.     function test_setCellAttributes_fail_invalid_cellindex()
  81.     {
  82.         if (!$this->_methodExists('setCellAttributes')) {
  83.             return;
  84.         }
  85.         $this->ui->setCellAttributes('',11);
  86.     }
  87.  
  88.     function test_setCellAttributes()
  89.     {
  90.         if (!$this->_methodExists('setCellAttributes')) {
  91.             return;
  92.         }
  93.         $this->ui->setCellAttributes('color = #FF0000');
  94.  
  95.         $this->assertFalse($this->errorThrown, 'error thrown');
  96.     }
  97. }
  98.  
  99. ?>
  100.