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

Source for file prepare.php

Documentation is available at prepare.php

  1. <?php
  2. /**
  3.  * prepare selenium tests
  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: prepare.php 141 2007-08-31 20:52:47Z m2mtech $
  24.  * @link       http://www.ea-geier.at/
  25.  */
  26.  
  27. if (!isset($_GET['what'])) exit;
  28.  
  29. chdir('../../')// set root directory
  30.  
  31. /**
  32.  * environment configuration
  33.  */
  34. require_once('code/config.php');
  35.  
  36. /**
  37.  * database wrapper
  38.  */
  39. require_once('code/base/db.class.php');
  40.  
  41. $db new eaDB($conf);
  42.  
  43. switch ($_GET['what']{
  44.     case 'newUserStart':
  45.         if ($db->isUser('test@ea-geier.at')) {    
  46.             $db->deleteUser('test@ea-geier.at');        
  47.             echo 'old test user deleted<br />';
  48.         }
  49.         break;
  50.     case 'newUserStop':
  51.         if ($db->isUser('test@ea-geier.at')) {    
  52.             $db->deleteUser('test@ea-geier.at');        
  53.             echo 'test user deleted<br />';
  54.         }
  55.         break;
  56.     case 'sendPWStart':
  57.         if (!$db->isUser('test@ea-geier.at')) 
  58.             $db->createUser('test@ea-geier.at''testpass');
  59.             echo 'test user created<br />';
  60.         }
  61.         break;
  62.     case 'sendPWStop':
  63.         if ($db->isUser('test@ea-geier.at')) {    
  64.             $db->deleteUser('test@ea-geier.at');        
  65.             echo 'test user deleted<br />';
  66.         }
  67.         break;
  68.     case 'loginStart':
  69.         if (!$db->isUser('test@ea-geier.at')) 
  70.             $db->createUser('test@ea-geier.at''testpass');
  71.             echo 'test user created<br />';
  72.         else {
  73.             $db->setPW('test@ea-geier.at''testpass');
  74.             echo 'password corrected<br />';
  75.         }
  76.         break;
  77.     case 'loginStop':
  78.         if ($db->isUser('test@ea-geier.at')) {    
  79.             $db->deleteUser('test@ea-geier.at');        
  80.             echo 'test user deleted<br />';
  81.         }
  82.         break;
  83.     case 'configStart':
  84.         if (!$db->isUser('test@ea-geier.at')) 
  85.             $db->createUser('test@ea-geier.at''testpass');
  86.             echo 'test user created<br />';
  87.         else {
  88.             $db->setPW('test@ea-geier.at''testpass');
  89.             echo 'password corrected<br />';
  90.         }
  91.         if (!$db->isUser('testdouble@ea-geier.at')) {    
  92.             $db->createUser('testdouble@ea-geier.at''testpass');
  93.             echo 'double user created<br />';
  94.         }
  95.         if ($db->isUser('testnew@ea-geier.at')) {
  96.             $db->deleteUser('testnew@ea-geier.at');
  97.             echo 'new user deleted<br />';
  98.         }
  99.         break;
  100.     case 'configStop':
  101.         if ($db->isUser('test@ea-geier.at')) 
  102.             $db->deleteUser('test@ea-geier.at');
  103.             echo 'test user deleted<br />';
  104.         }
  105.         if ($db->isUser('testdouble@ea-geier.at')) {    
  106.             $db->deleteUser('testdouble@ea-geier.at');
  107.             echo 'double user deleted<br />';
  108.         }
  109.         if ($db->isUser('testnew@ea-geier.at')) {
  110.             $db->deleteUser('testnew@ea-geier.at');
  111.             echo 'new user deleted<br />';
  112.         }
  113.         break;
  114.     case 'cashBookStart'case 'assetsStart'case 'purchaseBookStart':
  115.     case 'travelStart'case 'balanceStart':
  116.         if (!$db->isUser('test@ea-geier.at')) 
  117.             $db->createUser('test@ea-geier.at''testpass');
  118.             echo 'test user created<br />';
  119.         else {
  120.             $db->setPW('test@ea-geier.at''testpass');
  121.             echo 'password corrected<br />';
  122.         }
  123.         break;
  124.     case 'cashBookCreateClient'case 'assetsCreateClient'
  125.     case 'purchaseBookCreateClient'case 'travelCreateClient':
  126.         if (!$id $db->isUser('test@ea-geier.at''id')) {
  127.             echo 'no user existis - will not create client';
  128.             break;
  129.         }
  130.         $data['txtNewClientName''Test Client';
  131.         $user['id'$id;
  132.         if (!$db->select('id'$db->table('clients')array('owner' => $id))) {
  133.             $db->createClient($data$user);
  134.             echo 'test client created<br />';
  135.         }
  136.         break;
  137.     case 'balanceCreateClient':
  138.         if (!$id $db->isUser('test@ea-geier.at''id')) {
  139.             echo 'no user existis - will not create client';
  140.             break;
  141.         }
  142.         $data['txtNewClientName''Test Client';
  143.         $user['id'$id;
  144.         if (!$db->select('id'$db->table('clients')array('owner' => $id))) {
  145.             $db->createClient($data$usertrue);
  146.             echo 'test client created with demo data<br />';
  147.         }
  148.         break;
  149.     case 'cashBookStop'case 'assetsStop'case 'purchaseBookStop':
  150.     case 'travelStop'case 'balanceStop':
  151.         if ($db->isUser('test@ea-geier.at')) {    
  152.             $db->deleteUser('test@ea-geier.at');        
  153.             echo 'test user deleted<br />';
  154.         }
  155.         break;
  156. }    
  157.  
  158. unset($db);
  159.  
  160. /**
  161.  * mail wrapper
  162.  */
  163. require_once('code/base/mail.class.php');
  164.  
  165. if ($_GET['what'== 'sendPWStart'{
  166.     if (($conf['txtMailServer'== eaFAKEMAIL_SERVER&& ($conf['numMailPort'== eaFAKEMAIL_PORT&& (eaFAKEMAIL_DIR != 'none')) {
  167.         // check if fake mail server is running
  168.                 $mail new eaMail(eaFAKEMAIL_SERVEReaFAKEMAIL_PORT);
  169.         if ($mail->error{
  170.             $command eaFAKEMAIL_DIR 'fakemail --path=' eaFAKEMAIL_TMP ' --host=' eaFAKEMAIL_SERVER ' --port=' eaFAKEMAIL_PORT ' --background';
  171.             $pid = `$command`;
  172.             echo 'fake-mail server started';        
  173.         else echo 'fake-mail server already running<br />';
  174.     }
  175. }
  176.  
  177. if ($_GET['what'== 'sendPWStop'{
  178.     if (($conf['txtMailServer'== eaFAKEMAIL_SERVER&& ($conf['numMailPort'== eaFAKEMAIL_PORT&& (eaFAKEMAIL_DIR != 'none')) {
  179.         $output false;
  180.         if (exec('ps ax | grep fakemail'$output)) {
  181.             foreach ($output as $line{
  182.                 if (preg_match('/grep/'$line)) continue;
  183.                 $match false;
  184.                 if (preg_match('/[0-9]+/'$line$match)) {
  185.                     $command 'kill ' $match[0];
  186.                     `$command`;
  187.                     echo 'fake-mail server stopped';
  188.                 }                    
  189.             }
  190.         }
  191.     }
  192. }
  193.  
  194. ?>

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