use requires annotation

This commit is contained in:
Christian Flothmann 2015-12-22 09:19:23 +01:00
parent 65eb18849a
commit 2a6fa7bbab

View File

@ -45,19 +45,21 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
}
}
/**
* @requires PHP 5.3.7
*/
public function testResultLength()
{
$this->skipIfPhpVersionIsNotSupported();
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertEquals(60, strlen($result));
}
/**
* @requires PHP 5.3.7
*/
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));
@ -74,21 +76,15 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
$encoder->encodePassword(str_repeat('a', 73), 'salt');
}
/**
* @requires PHP 5.3.7
*/
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.');
}
}
}