Add Tests/userssqlTest.php
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2277 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
123
Tests/userssqlTest.php
Normal file
123
Tests/userssqlTest.php
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
/** DomFramework - Tests
|
||||||
|
@package domframework
|
||||||
|
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||||
|
|
||||||
|
/** Test the userssql.php file */
|
||||||
|
class test_userssql extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function test_clean ()
|
||||||
|
{
|
||||||
|
@unlink ("/tmp/database.db");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_initStorage ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->initStorage ();
|
||||||
|
$this->assertEquals ($res, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_listusers1 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->listusers ();
|
||||||
|
$this->assertEquals ($res, array ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_adduser1 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->adduser ("toto@toto.com", "Toto", "Toto2");
|
||||||
|
$this->assertEquals ($res, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_listusers2 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->listusers ();
|
||||||
|
$this->assertEquals ($res, array (array ("email"=>"toto@toto.com",
|
||||||
|
"firstname"=>"Toto",
|
||||||
|
"lastname"=>"Toto2")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_overwritepassword1 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->overwritepassword ("toto@toto.com", "PassW0rd");
|
||||||
|
$this->assertEquals ($res, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_checkValidPassword1 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->checkValidPassword ("toto@toto.com", "PassW0rd");
|
||||||
|
$this->assertEquals ($res, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_checkValidPassword2 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->checkValidPassword ("toto@toto.com", "BAD PASSWD");
|
||||||
|
$this->assertEquals ($res, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_changepassword1 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->changepassword ("toto@toto.com", "PassW0rd", "NEW PASS!");
|
||||||
|
$this->assertEquals ($res, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_checkValidPassword3 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->checkValidPassword ("toto@toto.com", "PassW0rd");
|
||||||
|
$this->assertEquals ($res, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_checkValidPassword4 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->checkValidPassword ("toto@toto.com", "NEW PASS!");
|
||||||
|
$this->assertEquals ($res, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_updateuser ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->updateuser ("toto@toto.com", "titi@titi.com", "titi",
|
||||||
|
"titi2");
|
||||||
|
$this->assertEquals ($res, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_listusers3 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->listusers ();
|
||||||
|
$this->assertEquals ($res, array (array ("email"=>"titi@titi.com",
|
||||||
|
"firstname"=>"titi",
|
||||||
|
"lastname"=>"titi2")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_checkValidPassword5 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->checkValidPassword ("titi@titi.com", "NEW PASS!");
|
||||||
|
$this->assertEquals ($res, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_deluser ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->deluser ("titi@titi.com");
|
||||||
|
$this->assertEquals ($res, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_listusers4 ()
|
||||||
|
{
|
||||||
|
$userssql = new userssql ("sqlite:///tmp/database.db");
|
||||||
|
$res = $userssql->listusers ();
|
||||||
|
$this->assertEquals ($res, array ());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user