ea-Geiertest
[ class tree: ea-Geier ] [ index: ea-Geier ] [ all elements ]

Source for file newuser.inc.php

Documentation is available at newuser.inc.php

  1. <?php
  2. /**
  3.  * test case for new-user functions
  4.  *
  5.  * LICENSE:
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
  13.  * GNU General Public License for more details.
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program; if not, write to the Free Software Foundation, Inc.,
  16.  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17.  *
  18.  * @package       ea-Geier
  19.  * @subpackage test
  20.  * @author       m2mtech <tech@m2m.at>
  21.  * @copyright  2007 m2m server software gmbh
  22.  * @license       http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
  23.  * @version       $Id: newuser.inc.php 59 2007-04-24 13:23:59Z m2mtech $
  24.  * @link       http://www.ea-geier.at/
  25.  */
  26.  
  27. /**
  28.  * functions to be tested
  29.  */
  30. require_once('code/base/newuser.inc.php');
  31.  
  32. /**
  33.  * helper class - input validator
  34.  */
  35. require_once('code/base/input.class.php');
  36. Mock::generate('eaInput');
  37.  
  38. /**
  39.  * helper class - database
  40.  */
  41. require_once('code/base/db.class.php');
  42. Mock::generate('eaDB');
  43.  
  44. /**
  45.  * test case for new-user functions
  46.  *
  47.  * @package       ea-Geier
  48.  */
  49. class TestNewUser extends UnitTestCase {
  50.     
  51.     /**
  52.      * constructor
  53.      */
  54.     function TestNewUser({
  55.         $this->UnitTestCase('Test New-User Functions');
  56.     }
  57.  
  58.     /**
  59.      * tests option generation
  60.      *
  61.      * - no real functionality at the moment
  62.      */
  63.     function testGenOpt({
  64.         $in false;
  65.     
  66.         genOptNewUser($in);
  67.     }
  68.  
  69.     /**
  70.      * tests saving new user
  71.      *
  72.      * checks
  73.      * - no post data
  74.      * - input error
  75.      * - missing variables
  76.      * - existing users
  77.      * - saving user
  78.      */
  79.     function testSave({
  80.         $in new MockeaInput();
  81.  
  82.         $db new MockeaDB();
  83.  
  84.         $this->assertFalse(saveNewUser($db$in)'no post data');
  85.         
  86.         $_POST['buttonNewUser'true// button pressed
  87.         
  88.         // input error
  89.         $in->error array('testinputerror' => true)
  90.         $this->assertFalse(saveNewUser($db$in));
  91.         $in->error array();
  92.         
  93.         // missing variable
  94.         $in->post array('mail' => 'testmail''pass' => 'testpass');
  95.         $this->assertFalse(saveNewUser($db$in));
  96.         $in->error array();
  97.  
  98.         // existing user
  99.         $in->post array('mail' => 'testmail''pass' => 'testpass''txtName' => 'testname');
  100.         $db->setReturnValueAt(0'isUser'true);    
  101.         $this->assertFalse(saveNewUser($db$in));
  102.         $in->error array();
  103.  
  104.         // user saved
  105.         $db->setReturnValueAt(1'isUser'false);    
  106.         $db->setReturnValue('createUser'true);
  107.         $result array('mail' => 'testmail''pw' => 'testpass''name' => 'testname');
  108.         $db->expect('createUser'array($result));
  109.         $this->assertTrue(saveNewUser($db$in));
  110.  
  111.         unset($_POST['buttonNewUser']);
  112.     }
  113.  
  114. }
  115. ?>

Documentation generated on Sun, 09 Sep 2007 17:09:11 +0200 by phpDocumentor 1.3.1