]> git.openstreetmap.org Git - nominatim.git/blob - test/php/Nominatim/ResultTest.php
Merge pull request #2328 from lonvia/convert-tiger-to-csv
[nominatim.git] / test / php / Nominatim / ResultTest.php
1 <?php
2
3 namespace Nominatim;
4
5 require_once(CONST_LibDir.'/Result.php');
6
7 function mkRankedResult($iId, $iResultRank)
8 {
9     $oResult = new Result($iId);
10     $oResult->iResultRank = $iResultRank;
11
12     return $oResult;
13 }
14
15
16 class ResultTest extends \PHPUnit\Framework\TestCase
17 {
18     public function testSplitResults()
19     {
20         $aSplitResults = Result::splitResults(array(
21             mkRankedResult(1, 2),
22             mkRankedResult(2, 0),
23             mkRankedResult(3, 0),
24             mkRankedResult(4, 2),
25             mkRankedResult(5, 1)
26         ));
27
28
29         $aHead = array_keys($aSplitResults['head']);
30         $aTail = array_keys($aSplitResults['tail']);
31
32         $this->assertEquals($aHead, array(2, 3));
33         $this->assertEquals($aTail, array(1, 4, 5));
34     }
35 }