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

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