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

  1. <?php
  2. require_once 'System.php';
  3. require_once 'PHPUnit.php';
  4. require_once 'File/Passwd/Common.php';
  5.  
  6. $tmpfile = System::mktemp();
  7.  
  8. /**
  9.  * TestCase for File_Passwd_CommonTest class
  10.  * Generated by PHPEdit.XUnit Plugin
  11.  * 
  12.  */
  13. class File_Passwd_CommonTest extends PHPUnit_TestCase{
  14.  
  15.     var $pwd;
  16.  
  17.     /**
  18.      * Constructor
  19.      * @param string $name The name of the test.
  20.      * @access protected
  21.      */
  22.     function File_Passwd_CommonTest($name){
  23.         $this->PHPUnit_TestCase($name);
  24.     }
  25.     
  26.     /**
  27.      * Called before the test functions will be executed this function is defined in PHPUnit_TestCase and overwritten here
  28.      * @access protected
  29.      */
  30.     function setUp(){
  31.         $this->pwd = &new File_Passwd_Common();
  32.     }
  33.     
  34.     /**
  35.      * Called after the test functions are executed this function is defined in PHPUnit_TestCase and overwritten here
  36.      * @access protected
  37.      */
  38.     function tearDown(){
  39.         $this->pwd = null;
  40.     }
  41.     
  42.     /**
  43.      * Regression test for File_Passwd_Common.parse method
  44.      * @access public
  45.      */
  46.     function testparse(){
  47.         $this->assertTrue(PEAR::isError($this->pwd->parse()));
  48.     }
  49.     
  50.     /**
  51.      * Regression test for File_Passwd_Common.save method
  52.      * @access public
  53.      */
  54.     function testsave(){
  55.         $this->assertTrue(PEAR::isError($this->pwd->save()));
  56.     }
  57.     
  58.     /**
  59.      * Regression test for File_Passwd_Common.load method
  60.      * @access public
  61.      */
  62.     function testload(){
  63.         $array = array('1stLine', '2ndLine', '3rdLine');
  64.         $this->pwd->setFile('common.txt');
  65.         $this->pwd->load();
  66.         $this->assertEquals($array, $this->pwd->_contents);
  67.     }
  68.     
  69.     /**
  70.      * Regression test for File_Passwd_Common.setFile method
  71.      * @access public
  72.      */
  73.     function testsetFile(){
  74.         $this->pwd->setFile('passwd.file');
  75.         $this->assertEquals('passwd.file', $this->pwd->getFile());
  76.     }
  77.     
  78.     /**
  79.      * Regression test for File_Passwd_Common.getFile method
  80.      * @access public
  81.      */
  82.     function testgetFile(){
  83.         $this->pwd->setFile('passwd.file');
  84.         $this->assertEquals('passwd.file', $this->pwd->getFile());
  85.     }
  86.     
  87.     /**
  88.      * Regression test for File_Passwd_Common.userExists method
  89.      * @access public
  90.      */
  91.     function testuserExists(){
  92.         $this->pwd->_users = array('mike' => array());
  93.         $this->assertTrue($this->pwd->userExists('mike'));
  94.     }
  95.     
  96.     /**
  97.      * Regression test for File_Passwd_Common.delUser method
  98.      * @access public
  99.      */
  100.     function testdelUser(){
  101.         $this->pwd->_users = array('mike' => array('nothing'));
  102.         $this->assertTrue($this->pwd->delUser('mike'));
  103.     }
  104.     
  105.     /**
  106.      * Regression test for File_Passwd_Common.listUser method
  107.      * @access public
  108.      */
  109.     function testlistUser(){
  110.         $array = array('mike' => array('nothing'));
  111.         $this->pwd->_users = $array;
  112.         $this->assertEquals($array, $this->pwd->listUser());
  113.         $this->assertEquals(array('nothing'), $this->pwd->listUser('mike'));
  114.     }
  115.     
  116.     function test_auth(){
  117.         $this->assertTrue('1stLine' === File_Passwd_Common::_auth('common.txt', '1stLine'));
  118.         $this->assertFalse(File_Passwd_Common::_auth('common.txt', 'nonexist'));
  119.     }
  120. }
  121.  
  122. ?>