PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/test/Unit/Random/Source/UniqIDTest.php

http://github.com/ircmaxell/PHP-PasswordLib
PHP | 39 lines | 24 code | 8 blank | 7 comment | 1 complexity | 452842611a12f741e2aeff06d1aadab3 MD5 | raw file
  1. <?php
  2. use PasswordLib\Random\Source\UniqID;
  3. use PasswordLib\Core\Strength;
  4. class Unit_Random_Source_UniqIDTest extends PHPUnit_Framework_TestCase {
  5. public static function provideGenerate() {
  6. $data = array();
  7. for ($i = 0; $i < 100; $i += 5) {
  8. $not = $i > 0 ? str_repeat(chr(0), $i) : chr(0);
  9. $data[] = array($i, $not);
  10. }
  11. return $data;
  12. }
  13. /**
  14. * @covers PasswordLib\Random\Source\UniqID::getStrength
  15. */
  16. public function testGetStrength() {
  17. $strength = new Strength(Strength::LOW);
  18. $actual = UniqID::getStrength();
  19. $this->assertEquals($actual, $strength);
  20. }
  21. /**
  22. * @covers PasswordLib\Random\Source\UniqID::generate
  23. * @dataProvider provideGenerate
  24. */
  25. public function testGenerate($length, $not) {
  26. $rand = new UniqID;
  27. $stub = $rand->generate($length);
  28. $this->assertEquals($length, strlen($stub));
  29. $this->assertNotEquals($not, $stub);
  30. }
  31. }