PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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