home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / Limit.php < prev    next >
Encoding:
PHP Script  |  2004-10-01  |  1.9 KB  |  69 lines

  1. <?php
  2. //
  3. //  $Id: Limit.php,v 1.1 2003/06/06 14:39:44 cain Exp $
  4. //
  5.  
  6. class tests_Limit extends tests_UnitTest
  7. {
  8.     // test if setLimit works
  9.     function test_setLimit()
  10.     {
  11.         $user = new tests_Common(TABLE_USER);
  12.         $user->setLimit(0,10);
  13.         $this->assertEquals(array(0,10),$user->getLimit());
  14.     }
  15.  
  16.     // test if setLimit works
  17.     function test_setLimit1()
  18.     {
  19.         $user = new tests_Common(TABLE_USER);
  20.         
  21.         $user->add(array('login'=>1));
  22.         $user->add(array('login'=>2));
  23.         $user->add(array('login'=>3));
  24.         $user->add(array('login'=>4));
  25.         
  26.         $user->setLimit(0,2);
  27.         $this->assertEquals(2,sizeof($user->getAll()));
  28.     
  29.         $user->setLimit(0,3);
  30.         $this->assertEquals(3,sizeof($user->getAll()));
  31.     }
  32.  
  33.     // test if getAll works
  34.     // setLimit should have no effect when parameters are given to getAll()
  35.     function test_getAll()
  36.     {
  37.         $user = new tests_Common(TABLE_USER);
  38.         $user->setLimit(0,10);
  39.         $user->add(array('login'=>1));
  40.         $user->add(array('login'=>2));
  41.         $user->add(array('login'=>3));
  42.         $user->add(array('login'=>4));
  43.         $this->assertEquals(1,sizeof($user->getAll(0,1)));
  44.         $user->setLimit(0,3);
  45.         $this->assertEquals(2,sizeof($user->getAll(0,2)));
  46.         
  47.         $this->assertEquals(3,sizeof($user->getAll()));
  48.     }
  49.  
  50.     // test if getAll works
  51.     // setLimit should have no effect when parameters are given to getAll()
  52.     function test_getCol()
  53.     {
  54.         $user = new tests_Common(TABLE_USER);
  55.         $user->setLimit(0,10);
  56.         $user->add(array('login'=>1));
  57.         $user->add(array('login'=>2));
  58.         $user->add(array('login'=>3));
  59.         $user->add(array('login'=>4));
  60.         $this->assertEquals(1,sizeof($user->getCol('id',0,1)));
  61.         $user->setLimit(0,3);
  62.         $this->assertEquals(2,sizeof($user->getCol('id',0,2)));
  63.         
  64.         $this->assertEquals(3,sizeof($user->getCol('id')));
  65.     }
  66. }
  67.  
  68. ?>
  69.