Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update tests for phpunit 10 and 11 #208

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions tests/CryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\TestCase;
use Rancoud\Crypt\Crypt;
use Rancoud\Crypt\CryptException;
Expand All @@ -12,6 +14,7 @@
* @runTestsInSeparateProcesses
* Class CryptTest.
*/
#[RunTestsInSeparateProcesses]
class CryptTest extends TestCase
{
// region Set specific algo
Expand All @@ -35,19 +38,19 @@ public function testUseArgon2id(): void

// region Hash / Verify / Needs Rehash

public function dataCasesGeneric(): array
public static function dataCasesGeneric(): array
{
return [
'Argon2id' => [
'use_algo' => 'useArgon2id',
'useAlgo' => 'useArgon2id',
'password' => 'my_password_argon_2id',
],
'Argon2i' => [
'use_algo' => 'useArgon2i',
'useAlgo' => 'useArgon2i',
'password' => 'my_password_argon_2i',
],
'Bcrypt' => [
'use_algo' => 'useBcrypt',
'useAlgo' => 'useBcrypt',
'password' => 'my_password_bcrypt',
],
];
Expand All @@ -61,6 +64,7 @@ public function dataCasesGeneric(): array
*
* @throws CryptException
*/
#[DataProvider('dataCasesGeneric')]
public function testHash(string $useAlgo, string $password): void
{
Crypt::$useAlgo();
Expand All @@ -76,6 +80,7 @@ public function testHash(string $useAlgo, string $password): void
*
* @throws CryptException
*/
#[DataProvider('dataCasesGeneric')]
public function testVerifyValid(string $useAlgo, string $password): void
{
Crypt::$useAlgo();
Expand All @@ -94,6 +99,7 @@ public function testVerifyValid(string $useAlgo, string $password): void
*
* @throws CryptException
*/
#[DataProvider('dataCasesGeneric')]
public function testVerifyInvalid(string $useAlgo, string $password): void
{
Crypt::$useAlgo();
Expand All @@ -112,6 +118,7 @@ public function testVerifyInvalid(string $useAlgo, string $password): void
*
* @throws CryptException
*/
#[DataProvider('dataCasesGeneric')]
public function testNeedsRehash(string $useAlgo, string $password): void
{
Crypt::$useAlgo();
Expand All @@ -133,23 +140,23 @@ public function testNeedsRehash(string $useAlgo, string $password): void
static::assertTrue($needsRehash);
}

public function dataCasesHashFailure(): array
public static function dataCasesHashFailure(): array
{
return [
'Argon2id' => [
'use_algo' => 'useArgon2id',
'password' => 'my_password_argon_2id',
'error_message' => 'Hash Failure',
'useAlgo' => 'useArgon2id',
'password' => 'my_password_argon_2id',
'errorMessage' => 'Hash Failure',
],
'Argon2i' => [
'use_algo' => 'useArgon2i',
'password' => 'my_password_argon_2i',
'error_message' => 'Hash Failure',
'useAlgo' => 'useArgon2i',
'password' => 'my_password_argon_2i',
'errorMessage' => 'Hash Failure',
],
'Bcrypt' => [
'use_algo' => 'useBcrypt',
'password' => 'azertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiop',
'error_message' => 'Password too long',
'useAlgo' => 'useBcrypt',
'password' => 'azertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiopazertyuiop',
'errorMessage' => 'Password too long',
]
];
}
Expand All @@ -163,6 +170,7 @@ public function dataCasesHashFailure(): array
*
* @throws CryptException
*/
#[DataProvider('dataCasesHashFailure')]
public function testHashFailure(string $useAlgo, string $password, string $errorMessage): void
{
Crypt::$useAlgo();
Expand Down
Loading