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

@@ -4,14 +4,18 @@
* @author Dominique Fournier <dominique@fournier38.fr>
*/
/** Test the encrypt.php file */
class encryptTest extends \PHPUnit_Framework_TestCase
namespace Domframework\Tests;
use Domframework\Encrypt;
/** Test the Encrypt.php file */
class EncryptTest extends \PHPUnit_Framework_TestCase
{
/** Check the length of the otken with cipher
*/
public function testEncrypt1 ()
{
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$res = $encrypt->encrypt ("TextToEncode",
"123456789012345678901234");
$this->assertSame (strlen ($res), 24);
@@ -21,7 +25,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypt2 ()
{
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "TextToEncode";
$ckey = "123456789012345678901234";
$token = $encrypt->encrypt ($payload, $ckey);
@@ -33,7 +37,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
*/
public function testEncrypt3 ()
{
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "TextToEncode";
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
$res = strpos ($token, "Text");
@@ -47,7 +51,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipher provided to encrypt method : doesn't exists in OpenSSL",
500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "TextToEncode";
$token = $encrypt->encrypt ($payload, "123456789012345678901234", "TOTO");
}
@@ -59,7 +63,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid payload provided to encrypt method : Not a string",
500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = array ("Invalid");
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
}
@@ -71,7 +75,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipherKey provided to encrypt method : ".
"length different of 24 chars", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$payload = "Payload";
$token = $encrypt->encrypt ($payload, "124");
}
@@ -83,7 +87,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipherKey provided to decrypt method : ".
"length different of 24 chars", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("zfz", "124");
}
@@ -93,7 +97,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid ciphertext provided to decrypt method : empty string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("", "124");
}
@@ -103,7 +107,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid ciphertext provided to decrypt method : not a string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt (array (), "124");
}
@@ -113,7 +117,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid cipherkey provided to decrypt method : not a string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("1224", array ());
}
@@ -123,7 +127,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"Invalid cipherMethod provided to decrypt method : not a string", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("1224", "1234", array ());
}
@@ -134,7 +138,7 @@ class encryptTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"Invalid cipherMethod provided to decrypt method : ".
"doesn't exists in OpenSSL", 500);
$encrypt = new encrypt ();
$encrypt = new Encrypt ();
$token = $encrypt->decrypt ("1224", "1234", "unknown");
}
}