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

  1. <?php
  2. //
  3. // $Id: SetDbInstance.php,v 1.1 2004/03/17 15:12:05 quipo Exp $
  4. //
  5.  
  6. /**
  7. * This class just checks if the query is returned, not if
  8. * the query was properly rendered. This should be subject to
  9. * some other tests!
  10. *
  11. * @package tests
  12. */
  13. class tests_SetDbInstance extends tests_UnitTest
  14. {
  15.     /**
  16.      * Check if the two instances are the same by comparing
  17.      * the fetchMode, since this is the easiest to compare if
  18.      * two objects are the same in PHP4.
  19.      * We can do that since the querytool sets the fetch mode to
  20.      * MDB_FETCHMODE_ASSOC.
  21.      * Not very nice but it works.
  22.      *
  23.      */
  24.     function test_default()
  25.     {
  26.         $db =& MDB::connect(DB_DSN);
  27.  
  28.         $qt =& new MDB_QueryTool();
  29.         $qt->setDbInstance($db);
  30.         $dbActual =& $qt->getDbInstance();
  31.         $this->assertEquals($db->fetchmode, $dbActual->fetchmode);
  32.     }
  33.  
  34.     /**
  35.      * Make sure the way we did it before works too.
  36.      * Passing the DB_DSN to the constructor should also work.
  37.      * And retreiving the db instance should result in a sub class
  38.      * of MDB_common.
  39.      */
  40.     function test_oldWay()
  41.     {
  42.         $qt =& new MDB_QueryTool(DB_DSN);
  43.         $db =& $qt->getDbInstance();
  44.         $this->assertTrue(is_a($db, 'mdb_common'));
  45.     }
  46.  
  47. }
  48.  
  49. ?>
  50.