10000 skip bcrypt tests on incompatible platforms · symfony/symfony@65eb188 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65eb188

Browse files
author
Christian Flothmann
committed
skip bcrypt tests on incompatible platforms
Not all PHP versions before 5.3.7 have backported fixes that make it possible to use `password_hash()` function. Therefore, we have to skip tests on not supported platforms.
1 parent 0c2f1d9 commit 65eb188

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ public function testCostInRange()
4747

4848
public function testResultLength()
4949
{
50+
$this->skipIfPhpVersionIsNotSupported();
51+
5052
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5153
$result = $encoder->encodePassword(self::PASSWORD, null);
5254
$this->assertEquals(60, strlen($result));
5355
}
5456

5557
public function testValidation()
5658
{
59+
$this->skipIfPhpVersionIsNotSupported();
60+
5761
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5862
$result = $encoder->encodePassword(self::PASSWORD, null);
5963
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
@@ -72,10 +76,19 @@ public function testEncodePasswordLength()
7276

7377
public function testCheckPasswordLength()
7478
{
79+
$this->skipIfPhpVersionIsNotSupported();
80+
7581
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
7682
$result = $encoder->encodePassword(str_repeat('a', 72), null);
7783

7884
$this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 73), 'salt'));
7985
$this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 72), 'salt'));
8086
}
87+
88+
private function skipIfPhpVersionIsNotSupported()
89+
{
90+
if (PHP_VERSION_ID < 50307 && !\PasswordCompat\binary\check()) {
91+
$this->markTestSkipped('Skipping test as this PHP version is not compatible with the ircmaxell/password-compat library.');
92+
}
93+
}
8194
}

0 commit comments

Comments
 (0)
0