home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / SetDbInstance.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.3 KB  |  65 lines

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP Version 4                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1997-2003 The PHP Group                                |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 2.02 of the PHP license,      |
  8. // | that is bundled with this package in the file LICENSE, and is        |
  9. // | available at through the world-wide-web at                           |
  10. // | http://www.php.net/license/2_02.txt.                                 |
  11. // | If you did not receive a copy of the PHP license and are unable to   |
  12. // | obtain it through the world-wide-web, please send a note to          |
  13. // | license@php.net so we can mail you a copy immediately.               |
  14. // +----------------------------------------------------------------------+
  15. // | Author:  Wolfram Kriesing <wolfram@kriesing.de>                      |
  16. // +----------------------------------------------------------------------+
  17. //
  18. // $Id: SetDbInstance.php,v 1.1 2003/09/23 11:18:20 cain Exp $
  19. //
  20.  
  21. /**
  22. * This class just checks if the query is returned, not if
  23. * the query was properly rendered. This should be subject to
  24. * some other tests!
  25. *
  26. * @package tests
  27. */
  28. class tests_SetDbInstance extends tests_UnitTest
  29. {
  30.     /**
  31.     * Check if the two instances are the same by comparing
  32.     * the fetchMode, since this is the easiest to compare if
  33.     * two objects are the same in PHP4.
  34.     * We can do that since the querytool sets the fetch mode to 
  35.     * DB_FETCHMODE_ASSOC.
  36.     * Not very nice but it works.
  37.     * 
  38.     */
  39.     function test_default()
  40.     {
  41.         $db =& DB::connect(DB_DSN);
  42.     
  43.         $qt =& new DB_QueryTool();
  44.         $qt->setDbInstance($db);
  45.         $dbActual =& $qt->getDbInstance();
  46.         $this->assertEquals($db->fetchMode,$dbActual->fetchMode);
  47.     }
  48.  
  49.     /**
  50.     * Make sure the way we did it before works too.
  51.     * Passing the DB_DSN to the constructor should also work.
  52.     * And retreiving the db instance should result in a sub class
  53.     * of DB_common.
  54.     */
  55.     function test_oldWay()
  56.     {
  57.         $qt =& new DB_QueryTool(DB_DSN);
  58.         $db =& $qt->getDbInstance();
  59.         $this->assertTrue(is_a($db,'db_common'));
  60.     }
  61.  
  62. }
  63.  
  64. ?>
  65.