Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)
This commit is contained in:
@@ -1,66 +1,68 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
/**
|
||||
* DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Password;
|
||||
|
||||
/** Test the Password class
|
||||
*/
|
||||
/**
|
||||
* Test the Password class
|
||||
*/
|
||||
class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_cryptPasswd_1()
|
||||
public function testCryptPasswd1()
|
||||
{
|
||||
$res = Password::cryptPasswd("AAA");
|
||||
$this->assertSame($res[0] == "$" && strlen($res) > 8, true);
|
||||
}
|
||||
|
||||
public function test_cryptPasswd_2()
|
||||
public function testCryptPasswd2()
|
||||
{
|
||||
// Test the randomization of the salt : must be different each time
|
||||
// Test the randomization of the salt : must be different each time
|
||||
$res1 = Password::cryptPasswd("AAA");
|
||||
echo "RES1=$res1\n";
|
||||
$res2 = Password::cryptPasswd("AAA");
|
||||
echo "RES2=$res2\n";
|
||||
$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
|
||||
$this->assertSame(count(array_unique([$res1, $res2, $res3])), 3);
|
||||
// Three passwords : each must have a different result
|
||||
}
|
||||
|
||||
public function test_cryptPasswd_3()
|
||||
public function testCryptPasswd3()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::cryptPasswd(false);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_MYSQL()
|
||||
public function testCryptPasswordMYSQL()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "MYSQL");
|
||||
$this->assertSame($res, "*5AF9D0EA5F6406FB0EDD0507F81C1D5CEBE8AC9C");
|
||||
}
|
||||
|
||||
public function test_cryptPassword_CRYPT_STD_DES()
|
||||
public function testCryptPasswordCRYPTSTDDES()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "CRYPT_STD_DES");
|
||||
$this->assertSame(strlen($res), 13);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_CRYPT_EXT_DES()
|
||||
public function testCryptPasswordCRYPTEXTDES()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "CRYPT_EXT_DES");
|
||||
$this->assertSame(strlen($res), 13);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_CRYPT_MD5()
|
||||
public function testCryptPasswordCRYPTMD5()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "CRYPT_MD5");
|
||||
@@ -70,7 +72,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_CRYPT_BLOWFISH()
|
||||
public function testCryptPasswordCRYPTBLOWFISH()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "CRYPT_BLOWFISH");
|
||||
@@ -80,7 +82,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_CRYPT_SHA256()
|
||||
public function testCryptPasswordCRYPTSHA256()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "CRYPT_SHA256");
|
||||
@@ -90,7 +92,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_CRYPT_SHA512()
|
||||
public function testCryptPasswordCRYPTSHA512()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "CRYPT_SHA512");
|
||||
@@ -100,7 +102,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_PASSWORD_BCRYPT()
|
||||
public function testCryptPasswordPASSWORDBCRYPT()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "PASSWORD_BCRYPT");
|
||||
@@ -110,7 +112,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_PASSWORD_ARGON2I()
|
||||
public function testCryptPasswordPASSWORDARGON2I()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "PASSWORD_ARGON2I");
|
||||
@@ -120,7 +122,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_PASSWORD_ARGON2ID()
|
||||
public function testCryptPasswordPASSWORDARGON2ID()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "PASSWORD_ARGON2ID");
|
||||
@@ -130,33 +132,33 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cryptPassword_UNKNOWN()
|
||||
public function testCryptPasswordUNKNOWN()
|
||||
{
|
||||
$this->expectException();
|
||||
$password = new password();
|
||||
$res = $password->cryptPassword("AAA", "UNKNOWN");
|
||||
}
|
||||
|
||||
public function test_checkPassword_1()
|
||||
public function testCheckPassword1()
|
||||
{
|
||||
$res = Password::checkPassword("AAA", "AAA");
|
||||
$this->assertSame($res, false);
|
||||
}
|
||||
|
||||
public function test_checkPassword_2()
|
||||
public function testCheckPassword2()
|
||||
{
|
||||
$crypt = Password::cryptPasswd("AAA");
|
||||
$res = Password::checkPassword("AAA", $crypt);
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
|
||||
public function test_checkPassword_3()
|
||||
public function testCheckPassword3()
|
||||
{
|
||||
$res = Password::checkPassword("AAA", Password::cryptPasswd("BBB"));
|
||||
$this->assertSame($res, false);
|
||||
}
|
||||
|
||||
public function test_checkPassword_4()
|
||||
public function testCheckPassword4()
|
||||
{
|
||||
$res = Password::checkPassword(
|
||||
"AAA",
|
||||
@@ -165,7 +167,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
|
||||
public function test_checkPassword_invalid1()
|
||||
public function testCheckPasswordInvalid1()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::checkPassword(
|
||||
@@ -174,74 +176,74 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_checkPassword_invalid2()
|
||||
public function testCheckPasswordInvalid2()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::checkPassword("AAA", false);
|
||||
}
|
||||
|
||||
public function test_generateASCII_defaultsize()
|
||||
public function testGenerateASCIIDefaultsize()
|
||||
{
|
||||
$res = Password::generateASCII();
|
||||
$this->assertSame(strlen($res), 12);
|
||||
}
|
||||
|
||||
public function test_generateASCII_toobig()
|
||||
public function testGenerateASCIIToobig()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::generateASCII(112);
|
||||
}
|
||||
|
||||
public function test_generateASCII_toosmall()
|
||||
public function testGenerateASCIIToosmall()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::generateASCII(0);
|
||||
}
|
||||
|
||||
public function test_generateAlphanum_defaultsize()
|
||||
public function testGenerateAlphanumDefaultsize()
|
||||
{
|
||||
$res = Password::generateAlphanum();
|
||||
$this->assertSame(strlen($res), 12);
|
||||
}
|
||||
|
||||
public function test_generateAlphanum_toobig()
|
||||
public function testGenerateAlphanumToobig()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::generateAlphanum(112);
|
||||
}
|
||||
|
||||
public function test_generateAlphanum_toosmall()
|
||||
public function testGenerateAlphanumToosmall()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::generateAlphanum(0);
|
||||
}
|
||||
|
||||
public function test_generateAlphabetical_defaultsize()
|
||||
public function testGenerateAlphabeticalDefaultsize()
|
||||
{
|
||||
$res = Password::generateAlphabetical();
|
||||
$this->assertSame(strlen($res), 12);
|
||||
}
|
||||
|
||||
public function test_generateAlphabetical_toobig()
|
||||
public function testGenerateAlphabeticalToobig()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::generateAlphabetical(112);
|
||||
}
|
||||
|
||||
public function test_generateAlphabetical_toosmall()
|
||||
public function testGenerateAlphabeticalToosmall()
|
||||
{
|
||||
$this->expectException();
|
||||
$res = Password::generateAlphabetical(0);
|
||||
}
|
||||
|
||||
public function test_listMethods_1()
|
||||
public function testListMethods1()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->listMethods();
|
||||
$this->assertSame(count($res) > 7, true);
|
||||
}
|
||||
|
||||
public function test_salt_1()
|
||||
public function testSalt1()
|
||||
{
|
||||
$password = new password();
|
||||
$res = $password->salt();
|
||||
|
||||
Reference in New Issue
Block a user