summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Flothmann <flothmann@basecom.de>2015-12-19 14:25:32 +0100
committerChristian Flothmann <flothmann@basecom.de>2015-12-19 15:13:08 +0100
commit5cbd8b6132fcf0d12e827cad0f0cd851af806feb (patch)
tree19b0fa9c4bc1f4fb1b267a8c58ecf6960053596d
parentad9416c7ecfd8ebb4cc57c8b044534b1cdaeb2ed (diff)
downloadsymfony-security-5cbd8b6132fcf0d12e827cad0f0cd851af806feb.zip
symfony-security-5cbd8b6132fcf0d12e827cad0f0cd851af806feb.tar.gz
symfony-security-5cbd8b6132fcf0d12e827cad0f0cd851af806feb.tar.bz2
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.
-rw-r--r--Tests/Core/Encoder/BCryptPasswordEncoderTest.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/Tests/Core/Encoder/BCryptPasswordEncoderTest.php
index 355850a..b3ddff6 100644
--- a/Tests/Core/Encoder/BCryptPasswordEncoderTest.php
+++ b/Tests/Core/Encoder/BCryptPasswordEncoderTest.php
@@ -47,6 +47,8 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
public function testResultLength()
{
+ $this->skipIfPhpVersionIsNotSupported();
+
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertEquals(60, strlen($result));
@@ -54,6 +56,8 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
public function testValidation()
{
+ $this->skipIfPhpVersionIsNotSupported();
+
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
@@ -72,10 +76,19 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
public function testCheckPasswordLength()
{
+ $this->skipIfPhpVersionIsNotSupported();
+
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
$result = $encoder->encodePassword(str_repeat('a', 72), null);
$this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 73), 'salt'));
$this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 72), 'salt'));
}
+
+ private function skipIfPhpVersionIsNotSupported()
+ {
+ if (PHP_VERSION_ID < 50307 && !\PasswordCompat\binary\check()) {
+ $this->markTestSkipped('Skipping test as this PHP version is not compatible with the ircmaxell/password-compat library.');
+ }
+ }
}