Passage en Namespace et tous les tests fonctionnels OK

This commit is contained in:
2021-05-10 11:48:15 +02:00
parent 536dd0d56b
commit eb30d8ef97
56 changed files with 1091 additions and 964 deletions

View File

@@ -7,24 +7,26 @@
namespace Domframework\Tests;
/** Test the password class
use Domframework\Password;
/** Test the Password class
*/
class passwordTest extends \PHPUnit_Framework_TestCase
class PasswordTest extends \PHPUnit_Framework_TestCase
{
public function test_cryptPasswd_1 ()
{
$res = \password::cryptPasswd ("AAA");
$res = Password::cryptPasswd ("AAA");
$this->assertSame ($res[0] == "$" && strlen ($res) > 8, true);
}
public function test_cryptPasswd_2 ()
{
// Test the randomization of the salt : must be different each time
$res1 = \password::cryptPasswd ("AAA");
$res1 = Password::cryptPasswd ("AAA");
echo "RES1=$res1\n";
$res2 = \password::cryptPasswd ("AAA");
$res2 = Password::cryptPasswd ("AAA");
echo "RES2=$res2\n";
$res3 = \password::cryptPasswd ("AAA");
$res3 = Password::cryptPasswd ("AAA");
echo "RES3=$res3\n";
$this->assertSame (count (array_unique (array ($res1, $res2, $res3))), 3);
// Three passwords : each must have a different result
@@ -33,7 +35,7 @@ class passwordTest extends \PHPUnit_Framework_TestCase
public function test_cryptPasswd_3 ()
{
$this->expectException ();
$res = \password::cryptPasswd (false);
$res = Password::cryptPasswd (false);
}
public function test_cryptPassword_MYSQL ()
@@ -127,26 +129,26 @@ class passwordTest extends \PHPUnit_Framework_TestCase
public function test_checkPassword_1 ()
{
$res = \password::checkPassword ("AAA", "AAA");
$res = Password::checkPassword ("AAA", "AAA");
$this->assertSame ($res, false);
}
public function test_checkPassword_2 ()
{
$crypt = \password::cryptPasswd ("AAA");
$res = \password::checkPassword ("AAA", $crypt);
$crypt = Password::cryptPasswd ("AAA");
$res = Password::checkPassword ("AAA", $crypt);
$this->assertSame ($res, true);
}
public function test_checkPassword_3 ()
{
$res = \password::checkPassword ("AAA", \password::cryptPasswd ("BBB"));
$res = Password::checkPassword ("AAA", Password::cryptPasswd ("BBB"));
$this->assertSame ($res, false);
}
public function test_checkPassword_4 ()
{
$res = \password::checkPassword ("AAA",
$res = Password::checkPassword ("AAA",
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
$this->assertSame ($res, true);
}
@@ -154,68 +156,68 @@ class passwordTest extends \PHPUnit_Framework_TestCase
public function test_checkPassword_invalid1 ()
{
$this->expectException ();
$res = \password::checkPassword (false,
$res = Password::checkPassword (false,
'$2y$11$Y.E98jbjgDpV61eK..9MT.klzTeg7ulO4WH/B5yA8cAGMIh.zoNXq');
}
public function test_checkPassword_invalid2 ()
{
$this->expectException ();
$res = \password::checkPassword ("AAA", false);
$res = Password::checkPassword ("AAA", false);
}
public function test_generateASCII_defaultsize ()
{
$res = \password::generateASCII ();
$res = Password::generateASCII ();
$this->assertSame (strlen ($res), 12);
}
public function test_generateASCII_toobig ()
{
$this->expectException ();
$res = \password::generateASCII (112);
$res = Password::generateASCII (112);
}
public function test_generateASCII_toosmall ()
{
$this->expectException ();
$res = \password::generateASCII (0);
$res = Password::generateASCII (0);
}
public function test_generateAlphanum_defaultsize ()
{
$res = \password::generateAlphanum ();
$res = Password::generateAlphanum ();
$this->assertSame (strlen ($res), 12);
}
public function test_generateAlphanum_toobig ()
{
$this->expectException ();
$res = \password::generateAlphanum (112);
$res = Password::generateAlphanum (112);
}
public function test_generateAlphanum_toosmall ()
{
$this->expectException ();
$res = \password::generateAlphanum (0);
$res = Password::generateAlphanum (0);
}
public function test_generateAlphabetical_defaultsize ()
{
$res = \password::generateAlphabetical ();
$res = Password::generateAlphabetical ();
$this->assertSame (strlen ($res), 12);
}
public function test_generateAlphabetical_toobig ()
{
$this->expectException ();
$res = \password::generateAlphabetical (112);
$res = Password::generateAlphabetical (112);
}
public function test_generateAlphabetical_toosmall ()
{
$this->expectException ();
$res = \password::generateAlphabetical (0);
$res = Password::generateAlphabetical (0);
}
public function test_listMethods_1 ()