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

PHPUnit tests: fix deprecation notices on PHPUnit 10 #9

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
60 changes: 54 additions & 6 deletions tests/unit/PasswordHashEndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class PasswordHashEndToEndTest extends TestCase {
* Test using the stronger but system-specific hashes, with a possible fallback to
* the weaker portable hashes.
*
* @dataProvider dataSets
* @dataProvider dataSetsSuccess
*
* @param string $input The text to hash and compare with.
*
Expand All @@ -33,7 +33,7 @@ public function testStrongerSystemSpecificHashSuccess($input) {
* Test using the stronger but system-specific hashes, with a possible fallback to
* the weaker portable hashes.
*
* @dataProvider dataSets
* @dataProvider dataSetsFail
*
* @param string $input The text to hash.
* @param string $compare The text to compare the hash with.
Expand All @@ -50,7 +50,7 @@ public function testStrongerSystemSpecificHashFail($input, $compare) {
/**
* Test using the weaker portable hashes.
*
* @dataProvider dataSets
* @dataProvider dataSetsSuccess
*
* @param string $input The text to hash and compare with.
*
Expand All @@ -67,7 +67,7 @@ public function testWeakerPortableHashSuccess($input) {
/**
* Test using the weaker portable hashes.
*
* @dataProvider dataSets
* @dataProvider dataSetsFail
*
* @param string $input The text to hash.
* @param string $compare The text to compare the hash with.
Expand All @@ -87,6 +87,30 @@ public function testWeakerPortableHashFail($input, $compare) {
*
* @return array
*/
public static function dataSetsSuccess() {
$data = self::dataSets();
foreach ($data as $key => $value) {
// The `compare` parameter is only needed for the "fail" tests.
unset($data[$key]['compare']);
}

return $data;
}

/**
* Data provider.
*
* @return array
*/
public static function dataSetsFail() {
return self::dataSets();
}

/**
* Data provider helper.
*
* @return array
*/
public static function dataSets() {
return array(
'initial test case' => array(
Expand All @@ -99,7 +123,7 @@ public static function dataSets() {
/**
* Test the generated hash is correctly calculated using the weaker portable hashes.
*
* @dataProvider dataGeneratedHash
* @dataProvider dataGeneratedHashSuccess
*
* @param string $expected_hash The expected password hash output.
* @param string $input The text to hash and compare with.
Expand All @@ -112,10 +136,25 @@ public function testGeneratedHashSuccess($expected_hash, $input) {
$this->assertTrue($t_hasher->CheckPassword($input, $expected_hash));
}

/**
* Data provider.
*
* @return array
*/
public static function dataGeneratedHashSuccess() {
$data = self::dataGeneratedHash();
foreach ($data as $key => $value) {
// The `compare` parameter is only needed for the "fail" tests.
unset($data[$key]['compare']);
}

return $data;
}

/**
* Test the generated hash is correctly calculated using the weaker portable hashes.
*
* @dataProvider dataGeneratedHash
* @dataProvider dataGeneratedHashFail
*
* @param string $expected_hash The expected password hash output.
* @param string $input Unused.
Expand All @@ -134,6 +173,15 @@ public function testGeneratedHashFail($expected_hash, $input, $compare) {
*
* @return array
*/
public static function dataGeneratedHashFail() {
return self::dataGeneratedHash();
}

/**
* Data provider helper.
*
* @return array
*/
public static function dataGeneratedHash() {
return array(
'initial test case' => array(
Expand Down