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

Skip to content

Commit 396f6cf

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 396f6cf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Tests\Core\Encoder;
1313

14+
use PasswordCompat\binary\check;
1415
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
1516

1617
/**
@@ -47,13 +48,17 @@ public function testCostInRange()
4748

4849
public function testResultLength()
4950
{
51+
$this->skipIfPhpVersionIsNotSupported();
52+
5053
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5154
$result = $encoder->encodePassword(self::PASSWORD, null);
5255
$this->assertEquals(60, strlen($result));
5356
}
5457

5558
public function testValidation()
5659
{
60+
$this->skipIfPhpVersionIsNotSupported();
61+
5762
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5863
$result = $encoder->encodePassword(self::PASSWORD, null);
5964
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
@@ -78,4 +83,11 @@ public function testCheckPasswordLength()
7883
$this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 73), 'salt'));
7984
$this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 72), 'salt'));
8085
}
86+
87+
private function skipIfPhpVersionIsNotSupported()
88+
{
89+
if (PHP_VERSION_ID < 50307 && !check()) {
90+
$this->markTestSkipped('Skipping test as this PHP version is not compatible with the ircmaxell/password-compat library.');
91+
}
92+
}
8193
}

0 commit comments

Comments
 (0)