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_setOrientation.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  3.7 KB  |  136 lines

  1. <?php
  2.  
  3. /**
  4.  * API setOrientation Unit tests for HTML_Progress_UI class.
  5.  * 
  6.  * @version    $Id: HTML_Progress_TestCase_UI_setOrientation.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_setOrientation 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_setOrientation($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 setOrientation.
  62.      *
  63.      */
  64.     function test_setOrientation_fail_no_integer()
  65.     {
  66.         if (!$this->_methodExists('setOrientation')) {
  67.             return;
  68.         }
  69.         $this->ui->setOrientation('');
  70.     }
  71.  
  72.     function test_setOrientation_fail_invalid_value()
  73.     {
  74.         if (!$this->_methodExists('setOrientation')) {
  75.             return;
  76.         }
  77.         $this->ui->setOrientation(0);
  78.     }
  79.  
  80.     function test_setOrientation_vertical_valid_width()
  81.     {
  82.         if (!$this->_methodExists('setOrientation')) {
  83.             return;
  84.         }
  85.         $this->ui->setOrientation(HTML_PROGRESS_BAR_VERTICAL);
  86.  
  87.         $this->assertEquals(24, $this->ui->_progress['progress']['width'], 
  88.             'default-size VERTICAL no-border : w=24 h=172.');
  89.     }
  90.  
  91.     function test_setOrientation_vertical_valid_height()
  92.     {
  93.         if (!$this->_methodExists('setOrientation')) {
  94.             return;
  95.         }
  96.         $this->ui->setOrientation(HTML_PROGRESS_BAR_VERTICAL);
  97.  
  98.         $this->assertEquals(172, $this->ui->_progress['progress']['height'], 
  99.             'default-size VERTICAL no-border : w=24 h=172.');
  100.     }
  101.  
  102.     function test_setOrientation_vertical_valid_cell_width()
  103.     {
  104.         if (!$this->_methodExists('setOrientation')) {
  105.             return;
  106.         }
  107.         $this->ui->setOrientation(HTML_PROGRESS_BAR_VERTICAL);
  108.  
  109.         $this->assertEquals(20, $this->ui->_progress['cell']['width'], 
  110.             'default-cell-size VERTICAL : w=20 h=15.');
  111.     }
  112.  
  113.     function test_setOrientation_vertical_valid_cell_height()
  114.     {
  115.         if (!$this->_methodExists('setOrientation')) {
  116.             return;
  117.         }
  118.         $this->ui->setOrientation(HTML_PROGRESS_BAR_VERTICAL);
  119.  
  120.         $this->assertEquals(15, $this->ui->_progress['cell']['height'], 
  121.             'default-cell-size VERTICAL : w=20 h=15.');
  122.     }
  123.  
  124.     function test_setOrientation_vertical()
  125.     {
  126.         if (!$this->_methodExists('setOrientation')) {
  127.             return;
  128.         }
  129.         $this->ui->setOrientation(HTML_PROGRESS_BAR_VERTICAL);
  130.  
  131.         $this->assertFalse($this->errorThrown, 'error thrown');
  132.     }
  133. }
  134.  
  135. ?>
  136.