3 * SPDX-License-Identifier: GPL-2.0-only
5 * This file is part of Nominatim. (https://nominatim.org)
7 * Copyright (C) 2022 by the Nominatim developer community.
8 * For a full list of authors see the git log.
13 require_once(CONST_LibDir.'/TokenList.php');
16 class TokenListTest extends \PHPUnit\Framework\TestCase
18 protected function setUp(): void
20 $this->oNormalizer = $this->getMockBuilder(\MockNormalizer::class)
21 ->setMethods(array('transliterate'))
23 $this->oNormalizer->method('transliterate')
24 ->will($this->returnCallback(function ($text) {
25 return strtolower($text);
29 private function wordResult($aFields)
37 'country_code' => null,
40 return array_merge($aRow, $aFields);
43 public function testList()
47 $this->assertEquals(0, $TL->count());
49 $TL->addToken('word1', 'token1');
50 $TL->addToken('word1', 'token2');
52 $this->assertEquals(1, $TL->count());
54 $this->assertTrue($TL->contains('word1'));
55 $this->assertEquals(array('token1', 'token2'), $TL->get('word1'));
57 $this->assertFalse($TL->contains('unknownword'));
58 $this->assertEquals(array(), $TL->get('unknownword'));