Source for file sendpw.inc.php
Documentation is available at sendpw.inc.php
* test case for send-password functions
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @author m2mtech <tech@m2m.at>
* @copyright 2007 m2m server software gmbh
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
* @version $Id: sendpw.inc.php 106 2007-08-01 20:19:37Z m2mtech $
* @link http://www.ea-geier.at/
require_once('code/base/sendpw.inc.php');
* helper class - input validator
require_once('code/base/input.class.php');
Mock::generate('eaInput');
* helper class - database
require_once('code/base/db.class.php');
* test case for send-password functions
$this->UnitTestCase('Test Send-Password Functions');
* start FakeMail server & remove old mails
if (exec('ps ax | grep fakemail', $output)) {
foreach ($output as $line) {
$command = 'kill ' . $match[0];
echo 'fake-mail server stopped';
* stop FakeMail server & remove mails
$command = 'kill ' . $this->pid;
* tests option generation
* - no real functionality at the moment
* tests password generation
* - generating of different passwords
$this->assertTrue($pw = genPW());
// generating different passwords
$this->assertTrue($pw != genPW());
$conf = $GLOBALS['conf'];
$this->assertFalse(sendPW($db, $in));
$_POST['buttonSendPW'] = true; // button pressed
$in->error = array('testinputerror' => true);
$this->assertFalse(sendPW($db, $in));
$this->assertFalse(sendPW($db, $in));
$in->post = array('mail' => 'test@ea-geier.at');
$db->setReturnValueAt(0, 'isUser', false);
$this->assertFalse(sendPW($db, $in));
$db->setReturnValueAt(1, 'isUser', true);
$db->setReturnValueAt(0, 'setPW', false);
$this->assertFalse(sendPW($db, $in));
$conf['mailFrom'] = 'server@ea-geier.at';
$db->setReturnValueAt(2, 'isUser', true);
$db->setReturnValueAt(1, 'setPW', true);
$this->assertTrue(sendPW($db, $in));
unset ($_POST['buttonSendPW']);
|