1<?php
2
3namespace ZxcvbnPhp\Test;
4
5use ZxcvbnPhp\Matchers\RepeatMatch;
6use ZxcvbnPhp\Searcher;
7use ZxcvbnPhp\Matchers\Repeat;
8
9class SearcherTest extends \PHPUnit_Framework_TestCase
10{
11
12    public function testMinimumEntropyMatchSequence()
13    {
14        $searcher = new Searcher();
15        // Test simple password with no matches.
16        $password = 'a';
17        $entropy = $searcher->getMinimumEntropy($password, array());
18        $this->assertEquals(log(26, 2), $entropy, 'Entropy incorrect for single character lowercase password');
19
20        // Test password with repeat pattern.
21        $password = 'aaa';
22        $match = new RepeatMatch($password, 0, 2, 'aaa', 'a');
23        $entropy = $searcher->getMinimumEntropy($password, array($match));
24        $this->assertEquals(log(26 * 3, 2), $entropy, "Entropy incorrect for '$password'");
25        $sequence = $searcher->matchSequence;
26        $this->assertSame($match, $sequence[0], "Best match incorrect");
27    }
28}