Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 210e9e4

Browse files
committed
skip test assertions that are no longer valid with PHP >= 8.2.18/8.3.5
1 parent a0deee5 commit 210e9e4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Symfony/Component/PasswordHasher/Tests/Hasher/NativePasswordHasherTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ public function testBcryptWithNulByte()
103103
$hasher = new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT);
104104
$plainPassword = "a\0b";
105105

106-
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
106+
if (\PHP_VERSION_ID < 80218 || \PHP_VERSION_ID >= 80300 && \PHP_VERSION_ID < 80305) {
107+
// password_hash() does not accept passwords containing NUL bytes since PHP 8.2.18 and 8.3.5
108+
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
109+
}
110+
107111
$this->assertTrue($hasher->verify($hasher->hash($plainPassword), $plainPassword));
108112
}
109113

src/Symfony/Component/PasswordHasher/Tests/Hasher/SodiumPasswordHasherTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public function testBcryptWithNulByte()
7878
$hasher = new SodiumPasswordHasher(null, null);
7979
$plainPassword = "a\0b";
8080

81-
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
81+
if (\PHP_VERSION_ID < 80218 || \PHP_VERSION_ID >= 80300 && \PHP_VERSION_ID < 80305) {
82+
// password_hash() does not accept passwords containing NUL bytes since PHP 8.2.18 and 8.3.5
83+
$this->assertFalse($hasher->verify(password_hash($plainPassword, \PASSWORD_BCRYPT, ['cost' => 4]), $plainPassword));
84+
}
85+
8286
$this->assertTrue($hasher->verify((new NativePasswordHasher(null, null, 4, \PASSWORD_BCRYPT))->hash($plainPassword), $plainPassword));
8387
}
8488

0 commit comments

Comments
 (0)