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

  1. <?php
  2.  
  3. /**
  4.  * API getDM Unit tests for HTML_Progress class.
  5.  * 
  6.  * @version    $Id: HTML_Progress_TestCase_getDM.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_getDM extends PHPUnit_TestCase
  12. {
  13.     /**
  14.      * HTML_Progress instance
  15.      *
  16.      * @var        object
  17.      */
  18.     var $progress;
  19.  
  20.     function HTML_Progress_TestCase_getDM($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 getDM.
  62.      *
  63.      */
  64.     function test_getDM_fail()
  65.     {
  66.         if (!$this->_methodExists('getDM')) {
  67.             return;
  68.         }
  69.         $dm =& $this->progress->getDM();
  70.  
  71.         $this->assertSame($this, $dm, 'Wrong dataModel instance;');
  72.     }
  73.  
  74.     function test_getDM()
  75.     {
  76.         if (!$this->_methodExists('getDM')) {
  77.             return;
  78.         }
  79.         $dm =& $this->progress->getDM();
  80.  
  81.         $this->assertSame($this->progress->_DM, $dm);
  82.     }
  83. }
  84.  
  85. ?>
  86.