/class/libraries/vendor/ircmaxell/random-lib/test/Unit/RandomLib/Mixer/HashTest.php

https://gitlab.com/VoyaTrax/vtCMS2 · PHP · 51 lines · 37 code · 10 blank · 4 comment · 0 complexity · f03d3161e734b101d222e4d64561ba58 MD5 · raw file

  1. <?php
  2. namespace RandomLib\Mixer;
  3. use SecurityLib\Strength;
  4. class HashTest extends \PHPUnit_Framework_TestCase {
  5. public static function provideMix() {
  6. $data = array(
  7. array(array(), ''),
  8. array(array('1', '1'), '0d'),
  9. array(array('a'), '61'),
  10. // This expects 'b' because of how the mock hmac function works
  11. array(array('a', 'b'), '9a'),
  12. array(array('aa', 'ba'), '6e84'),
  13. array(array('ab', 'bb'), 'b0cb'),
  14. array(array('aa', 'bb'), 'ae8d'),
  15. array(array('aa', 'bb', 'cc'), 'a14c'),
  16. array(array('aabbcc', 'bbccdd', 'ccddee'), 'a8aff3939934'),
  17. );
  18. return $data;
  19. }
  20. public function testConstructWithoutArgument() {
  21. $hash = new Hash;
  22. $this->assertTrue($hash instanceof \RandomLib\Mixer);
  23. }
  24. public function testGetStrength() {
  25. $strength = new Strength(Strength::MEDIUM);
  26. $actual = Hash::getStrength();
  27. $this->assertEquals($actual, $strength);
  28. }
  29. public function testTest() {
  30. $actual = Hash::test();
  31. $this->assertTrue($actual);
  32. }
  33. /**
  34. * @dataProvider provideMix
  35. */
  36. public function testMix($parts, $result) {
  37. $mixer = new Hash('md5');
  38. $actual = $mixer->mix($parts);
  39. $this->assertEquals($result, bin2hex($actual));
  40. }
  41. }