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

  1. <?php
  2. //
  3. //  $Id: GetCount.php,v 1.2 2004/03/19 01:08:50 quipo Exp $
  4. //
  5.  
  6. class tests_GetCount extends tests_UnitTest
  7. {
  8.     function _setup($mode)
  9.     {
  10.         $this->user = new tests_Common(TABLE_USER);
  11.         switch ($mode) {
  12.             case '6':
  13.                 $this->user->add(array('name'=>'x'));
  14.                 $this->user->add(array('name'=>'y'));
  15.                 $this->user->add(array('name'=>'z'));
  16.             case '3':
  17.                 $this->user->add(array('name'=>'x'));
  18.                 $this->user->add(array('name'=>'y'));
  19.                 $this->user->add(array('name'=>'z'));
  20.                 break;
  21.         }
  22.     }
  23.  
  24.     function test_getCount3()
  25.     {
  26.         $this->_setup(3);
  27.         $this->assertEquals(3,$this->user->getCount(),'Wrong count after inserting 3 rows');
  28.     }
  29.  
  30.     function test_getCount6()
  31.     {
  32.         $this->_setup(6);
  33.         $this->assertEquals(6,$this->user->getCount(),'Wrong count after inserting 6 rows');
  34.     }
  35.  
  36.     function test_getCountGrouped3()
  37.     {
  38.         $this->_setup(6);
  39.         $this->user->setGroup('name');
  40.         $this->assertEquals(3,$this->user->getCount(),'Wrong count after 6 inserted and grouping them by name');
  41.     }
  42.  
  43.     function test_getCountGrouped2()
  44.     {
  45.         $this->_setup(6);
  46.         $this->user->setWhere("name='z'");
  47.         $this->assertEquals(2,$this->user->getCount(),'setWhere and setGroup should have resulted in two');
  48.     }
  49.  
  50.     function test_getCountGrouped1()
  51.     {
  52.         $this->_setup(6);
  53.         $this->user->setGroup('name');
  54.         $this->user->setWhere("name='z'");
  55.         $this->assertEquals(1,$this->user->getCount(),'setWhere and setGroup should have resulted in one');
  56.     }
  57.  
  58.     function test_getCountGrouped0()
  59.     {
  60.         $this->_setup(6);
  61.         $this->user->setGroup('name');
  62.         $this->user->setWhere("name='xxx'");
  63.         $this->assertEquals(0,$this->user->getCount(),'setWhere and setGroup should have resulted in one');
  64.     }
  65.  
  66. }
  67.  
  68. ?>
  69.