PasswordNeedsRehashTest.php 941 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class PasswordNeedsRehashTest extends PHPUnit_Framework_TestCase {
  3. public static function provideCases() {
  4. return array(
  5. array('foo', 0, array(), false),
  6. array('foo', 1, array(), true),
  7. array('$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', PASSWORD_BCRYPT, array(), true),
  8. array('$2y$07$usesomesillystringfore2udlvp1ii2e./u9c8sbjqp8i90dh6hi', PASSWORD_BCRYPT, array('cost' => 7), false),
  9. array('$2y$07$usesomesillystringfore2udlvp1ii2e./u9c8sbjqp8i90dh6hi', PASSWORD_BCRYPT, array('cost' => 5), true),
  10. );
  11. }
  12. public function testFuncExists() {
  13. $this->assertTrue(function_exists('password_needs_rehash'));
  14. }
  15. /**
  16. * @dataProvider provideCases
  17. */
  18. public function testCases($hash, $algo, $options, $valid) {
  19. $this->assertEquals($valid, password_needs_rehash($hash, $algo, $options));
  20. }
  21. }