working-directory: Nominatim
if: matrix.flavour != 'oldstuff'
- legacy-test:
- needs: create-archive
- runs-on: ubuntu-20.04
-
- strategy:
- matrix:
- postgresql: ["13", "16"]
-
- steps:
- - uses: actions/download-artifact@v4
- with:
- name: full-source
-
- - name: Unpack Nominatim
- run: tar xf nominatim-src.tar.bz2
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: '7.4'
-
- - uses: ./Nominatim/.github/actions/setup-postgresql
- with:
- postgresql-version: ${{ matrix.postgresql }}
- postgis-version: 3
-
- - name: Install Postgresql server dev
- run: sudo apt-get install postgresql-server-dev-$PGVER
- env:
- PGVER: ${{ matrix.postgresql }}
-
- - uses: ./Nominatim/.github/actions/build-nominatim
- with:
- cmake-args: -DBUILD_MODULE=on
-
- - name: Install test prerequisites
- run: sudo apt-get install -y -qq python3-behave
-
- - name: BDD tests (legacy tokenizer)
- run: |
- export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
- python3 -m behave -DREMOVE_TEMPLATE=1 -DSERVER_MODULE_PATH=$GITHUB_WORKSPACE/build/module -DAPI_ENGINE=php -DTOKENIZER=legacy --format=progress3
- working-directory: Nominatim/test/bdd
-
-
- php-test:
- needs: create-archive
- runs-on: ubuntu-22.04
-
- steps:
- - uses: actions/download-artifact@v4
- with:
- name: full-source
-
- - name: Unpack Nominatim
- run: tar xf nominatim-src.tar.bz2
-
- - uses: ./Nominatim/.github/actions/setup-postgresql
- with:
- postgresql-version: 15
- postgis-version: 3
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: 8.1
- tools: phpunit:9, phpcs, composer
- ini-values: opcache.jit=disable
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- - name: PHP linting
- run: phpcs --report-width=120 .
- working-directory: Nominatim
-
- - name: PHP unit tests
- run: phpunit ./
- working-directory: Nominatim/test/php
-
- - uses: ./Nominatim/.github/actions/build-nominatim
- with:
- flavour: 'ubuntu-22'
-
- - name: Install test prerequisites
- run: sudo apt-get install -y -qq python3-behave
-
- - name: BDD tests (php)
- run: |
- export PATH=$GITHUB_WORKSPACE/build/osm2pgsql:$PATH
- python3 -m behave -DREMOVE_TEMPLATE=1 -DAPI_ENGINE=php --format=progress3
- working-directory: Nominatim/test/bdd
-
-
install:
runs-on: ubuntu-latest
needs: create-archive
-all: bdd php python
-no-test-db: bdd-no-test-db php
+all: bdd python
bdd:
cd bdd && behave -DREMOVE_TEMPLATE=1
-php:
- cd php && phpunit ./
-
python:
pytest python
-.PHONY: bdd php no-test-db python
+.PHONY: bdd python
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/init-website.php');
-require_once(CONST_LibDir.'/AddressDetails.php');
-
-
-class AddressDetailsTest extends \PHPUnit\Framework\TestCase
-{
-
- protected function setUp(): void
- {
- // How the fixture got created
- //
- // 1) search for '10 downing street'
- // https://nominatim.openstreetmap.org/details.php?osmtype=R&osmid=1879842
- //
- // 2) find place_id in the local database
- // SELECT place_id, name FROM placex WHERE osm_type='R' AND osm_id=1879842;
- //
- // 3) set postgresql to non-align output, e.g. psql -A or \a in the CLI
- //
- // 4) query
- // SELECT row_to_json(row,true) FROM (
- // SELECT *, get_name_by_language(name, ARRAY['name:en']) as localname
- // FROM get_addressdata(194663412,10)
- // ORDER BY rank_address DESC, isaddress DESC
- // ) AS row;
- //
- // 5) copy&paste into file. Add commas between records
- //
- $json = file_get_contents(CONST_DataDir.'/test/php/fixtures/address_details_10_downing_street.json');
- $data = json_decode($json, true);
-
- $this->oDbStub = $this->getMockBuilder(\DB::class)
- ->setMethods(array('getAll'))
- ->getMock();
- $this->oDbStub->method('getAll')
- ->willReturn($data);
- }
-
- public function testGetLocaleAddress()
- {
- $oAD = new AddressDetails($this->oDbStub, 194663412, 10, 'en');
- $expected = join(', ', array(
- '10 Downing Street',
- '10',
- 'Downing Street',
- 'St. James\'s',
- 'Covent Garden',
- 'Westminster',
- 'London',
- 'Greater London',
- 'England',
- 'SW1A 2AA',
- 'United Kingdom'
- ));
- $this->assertEquals($expected, $oAD->getLocaleAddress());
- }
-
- public function testGetAddressDetails()
- {
- $oAD = new AddressDetails($this->oDbStub, 194663412, 10, 'en');
- $this->assertEquals(18, count($oAD->getAddressDetails(true)));
- $this->assertEquals(12, count($oAD->getAddressDetails(false)));
- }
-
- public function testGetAddressNames()
- {
- $oAD = new AddressDetails($this->oDbStub, 194663412, 10, 'en');
- $expected = array(
- 'tourism' => '10 Downing Street',
- 'house_number' => '10',
- 'road' => 'Downing Street',
- 'neighbourhood' => 'St. James\'s',
- 'suburb' => 'Covent Garden',
- 'city' => 'London',
- 'state_district' => 'Greater London',
- 'state' => 'England',
- 'ISO3166-2-lvl4' => 'GB-ENG',
- 'ISO3166-2-lvl6' => 'GB-LND',
- 'postcode' => 'SW1A 2AA',
- 'country' => 'United Kingdom',
- 'country_code' => 'gb'
- );
-
- $this->assertEquals($expected, $oAD->getAddressNames());
- }
-
- public function testGetAdminLevels()
- {
- $oAD = new AddressDetails($this->oDbStub, 194663412, 10, 'en');
- $expected = array(
- 'level8' => 'Westminster',
- 'level6' => 'London',
- 'level5' => 'Greater London',
- 'level4' => 'England',
- 'level2' => 'United Kingdom'
- );
- $this->assertEquals($expected, $oAD->getAdminLevels());
- }
-
- public function testDebugInfo()
- {
- $oAD = new AddressDetails($this->oDbStub, 194663412, 10, 'en');
- $this->assertTrue(is_array($oAD->debugInfo()));
- $this->assertEquals(18, count($oAD->debugInfo()));
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/ClassTypes.php');
-
-class ClassTypesTest extends \PHPUnit\Framework\TestCase
-{
- public function testGetLabelTag()
- {
- $aPlace = array('class' => 'boundary', 'type' => 'administrative',
- 'rank_address' => '4', 'place_type' => 'city');
- $this->assertEquals('city', ClassTypes\getLabelTag($aPlace));
-
- $aPlace = array('class' => 'boundary', 'type' => 'administrative',
- 'rank_address' => '10');
- $this->assertEquals('state_district', ClassTypes\getLabelTag($aPlace));
-
- $aPlace = array('class' => 'boundary', 'type' => 'administrative');
- $this->assertEquals('administrative', ClassTypes\getLabelTag($aPlace));
-
- $aPlace = array('class' => 'place', 'type' => 'hamlet', 'rank_address' => '20');
- $this->assertEquals('hamlet', ClassTypes\getLabelTag($aPlace));
-
- $aPlace = array('class' => 'highway', 'type' => 'residential',
- 'rank_address' => '26');
- $this->assertEquals('road', ClassTypes\getLabelTag($aPlace));
-
- $aPlace = array('class' => 'place', 'type' => 'house_number',
- 'rank_address' => '30');
- $this->assertEquals('house_number', ClassTypes\getLabelTag($aPlace));
-
- $aPlace = array('class' => 'amenity', 'type' => 'prison',
- 'rank_address' => '30');
- $this->assertEquals('amenity', ClassTypes\getLabelTag($aPlace));
- }
-
- public function testGetLabel()
- {
- $aPlace = array('class' => 'boundary', 'type' => 'administrative',
- 'rank_address' => '4', 'place_type' => 'city');
- $this->assertEquals('City', ClassTypes\getLabel($aPlace));
-
- $aPlace = array('class' => 'boundary', 'type' => 'administrative',
- 'rank_address' => '10');
- $this->assertEquals('State District', ClassTypes\getLabel($aPlace));
-
- $aPlace = array('class' => 'boundary', 'type' => 'administrative');
- $this->assertEquals('Administrative', ClassTypes\getLabel($aPlace));
-
- $aPlace = array('class' => 'amenity', 'type' => 'prison');
- $this->assertEquals('Prison', ClassTypes\getLabel($aPlace));
-
- $aPlace = array('class' => 'amenity', 'type' => 'foobar');
- $this->assertNull(ClassTypes\getLabel($aPlace));
- }
-
- public function testGetBoundaryLabel()
- {
- $this->assertEquals('City', ClassTypes\getBoundaryLabel(8, null));
- $this->assertEquals('Administrative', ClassTypes\getBoundaryLabel(18, null));
- $this->assertEquals('None', ClassTypes\getBoundaryLabel(18, null, 'None'));
- $this->assertEquals('State', ClassTypes\getBoundaryLabel(4, 'de', 'None'));
- $this->assertEquals('County', ClassTypes\getBoundaryLabel(4, 'se', 'None'));
- $this->assertEquals('Municipality', ClassTypes\getBoundaryLabel(7, 'se', 'None'));
- }
-
- public function testGetDefRadius()
- {
- $aResult = array('class' => '', 'type' => '');
- $this->assertEquals(0.00005, ClassTypes\getDefRadius($aResult));
-
- $aResult = array('class' => 'place', 'type' => 'country');
- $this->assertEquals(7, ClassTypes\getDefRadius($aResult));
- }
-
- public function testGetIcon()
- {
- $aResult = array('class' => '', 'type' => '');
- $this->assertNull(ClassTypes\getIcon($aResult));
-
- $aResult = array('class' => 'place', 'type' => 'airport');
- $this->assertEquals('transport_airport2', ClassTypes\getIcon($aResult));
- }
-
- public function testGetImportance()
- {
- $aResult = array('class' => '', 'type' => '');
- $this->assertNull(ClassTypes\getImportance($aResult));
-
- $aResult = array('class' => 'place', 'type' => 'airport');
- $this->assertGreaterThan(0, ClassTypes\getImportance($aResult));
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/lib.php');
-require_once(CONST_LibDir.'/DB.php');
-
-// subclassing so we can set the protected connection variable
-class NominatimSubClassedDB extends \Nominatim\DB
-{
- public function setConnection($oConnection)
- {
- $this->connection = $oConnection;
- }
-}
-
-// phpcs:ignore PSR1.Classes.ClassDeclaration.MultipleClasses
-class DBTest extends \PHPUnit\Framework\TestCase
-{
- public function testReusingConnection()
- {
- $oDB = new NominatimSubClassedDB('');
- $oDB->setConnection('anything');
- $this->assertTrue($oDB->connect());
- }
-
- public function testCheckConnection()
- {
- $oDB = new \Nominatim\DB('');
- $this->assertFalse($oDB->checkConnection());
- }
-
- public function testErrorHandling()
- {
- $this->expectException(DatabaseError::class);
- $this->expectExceptionMessage('Failed to establish database connection');
-
- $oDB = new \Nominatim\DB('pgsql:dbname=abc');
- $oDB->connect();
- }
-
- public function testErrorHandling2()
- {
- $this->expectException(DatabaseError::class);
- $this->expectExceptionMessage('Database query failed');
-
- $oPDOStub = $this->getMockBuilder(PDO::class)
- ->setMethods(array('query', 'quote'))
- ->getMock();
-
- $oPDOStub->method('query')
- ->will($this->returnCallback(function ($sVal) {
- return "'$sVal'";
- }));
-
- $oPDOStub->method('query')
- ->will($this->returnCallback(function () {
- throw new \PDOException('ERROR: syntax error at or near "FROM"');
- }));
-
- $oDB = new NominatimSubClassedDB('');
- $oDB->setConnection($oPDOStub);
- $oDB->getOne('SELECT name FROM');
- }
-
- public function testGetPostgresVersion()
- {
- $oDBStub = $this->getMockBuilder(\Nominatim\DB::class)
- ->disableOriginalConstructor()
- ->setMethods(array('getOne'))
- ->getMock();
-
- $oDBStub->method('getOne')
- ->willReturn('100006');
-
- $this->assertEquals(10, $oDBStub->getPostgresVersion());
- }
-
- public function testGetPostgisVersion()
- {
- $oDBStub = $this->getMockBuilder(\Nominatim\DB::class)
- ->disableOriginalConstructor()
- ->setMethods(array('getOne'))
- ->getMock();
-
- $oDBStub->method('getOne')
- ->willReturn('2.4.4');
-
- $this->assertEquals(2.4, $oDBStub->getPostgisVersion());
- }
-
- public function testParseDSN()
- {
- $this->assertEquals(
- array(),
- \Nominatim\DB::parseDSN('')
- );
- $this->assertEquals(
- array(
- 'database' => 'db1',
- 'hostspec' => 'machine1'
- ),
- \Nominatim\DB::parseDSN('pgsql:dbname=db1;host=machine1')
- );
- $this->assertEquals(
- array(
- 'database' => 'db1',
- 'hostspec' => 'machine1',
- 'port' => '1234',
- 'username' => 'john',
- 'password' => 'secret'
- ),
- \Nominatim\DB::parseDSN('pgsql:dbname=db1;host=machine1;port=1234;user=john;password=secret')
- );
- }
-
- public function testGenerateDSN()
- {
- $this->assertEquals(
- 'pgsql:',
- \Nominatim\DB::generateDSN(array())
- );
- $this->assertEquals(
- 'pgsql:host=machine1;dbname=db1',
- \Nominatim\DB::generateDSN(\Nominatim\DB::parseDSN('pgsql:host=machine1;dbname=db1'))
- );
- }
-
- public function testAgainstDatabase()
- {
- $unit_test_dsn = getenv('UNIT_TEST_DSN') != false ?
- getenv('UNIT_TEST_DSN') :
- 'pgsql:dbname=nominatim_unit_tests';
-
- ## Create the database.
- {
- $aDSNParsed = \Nominatim\DB::parseDSN($unit_test_dsn);
- $sDbname = $aDSNParsed['database'];
- $aDSNParsed['database'] = 'postgres';
-
- $oDB = new \Nominatim\DB(\Nominatim\DB::generateDSN($aDSNParsed));
- $oDB->connect();
- $oDB->exec('DROP DATABASE IF EXISTS ' . $sDbname);
- $oDB->exec('CREATE DATABASE ' . $sDbname);
- }
-
- $oDB = new \Nominatim\DB($unit_test_dsn);
- $oDB->connect();
-
- $this->assertTrue(
- $oDB->checkConnection($sDbname)
- );
-
- # Tables, Indices
- {
- $oDB->exec('CREATE TABLE table1 (id integer, city varchar, country varchar)');
-
- $this->assertTrue($oDB->tableExists('table1'));
- $this->assertFalse($oDB->tableExists('table99'));
- $this->assertFalse($oDB->tableExists(null));
- }
-
- # select queries
- {
- $oDB->exec(
- "INSERT INTO table1 VALUES (1, 'Berlin', 'Germany'), (2, 'Paris', 'France')"
- );
-
- $this->assertEquals(
- array(
- array('city' => 'Berlin'),
- array('city' => 'Paris')
- ),
- $oDB->getAll('SELECT city FROM table1')
- );
- $this->assertEquals(
- array(),
- $oDB->getAll('SELECT city FROM table1 WHERE id=999')
- );
-
-
- $this->assertEquals(
- array('id' => 1, 'city' => 'Berlin', 'country' => 'Germany'),
- $oDB->getRow('SELECT * FROM table1 WHERE id=1')
- );
- $this->assertEquals(
- false,
- $oDB->getRow('SELECT * FROM table1 WHERE id=999')
- );
-
-
- $this->assertEquals(
- array('Berlin', 'Paris'),
- $oDB->getCol('SELECT city FROM table1')
- );
- $this->assertEquals(
- array(),
- $oDB->getCol('SELECT city FROM table1 WHERE id=999')
- );
-
- $this->assertEquals(
- 'Berlin',
- $oDB->getOne('SELECT city FROM table1 WHERE id=1')
- );
- $this->assertEquals(
- null,
- $oDB->getOne('SELECT city FROM table1 WHERE id=999')
- );
-
- $this->assertEquals(
- array('Berlin' => 'Germany', 'Paris' => 'France'),
- $oDB->getAssoc('SELECT city, country FROM table1')
- );
- $this->assertEquals(
- array(),
- $oDB->getAssoc('SELECT city, country FROM table1 WHERE id=999')
- );
- }
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/init-website.php');
-require_once(CONST_LibDir.'/DatabaseError.php');
-
-class DatabaseErrorTest extends \PHPUnit\Framework\TestCase
-{
-
- public function testSqlMessage()
- {
- $oSqlStub = $this->getMockBuilder(PDOException::class)
- ->setMethods(array('getMessage'))
- ->getMock();
-
- $oSqlStub->method('getMessage')
- ->willReturn('Unknown table.');
-
- $oErr = new DatabaseError('Sql error', 123, null, $oSqlStub);
- $this->assertEquals('Sql error', $oErr->getMessage());
- $this->assertEquals(123, $oErr->getCode());
- $this->assertEquals('Unknown table.', $oErr->getSqlError());
- }
-
- public function testSqlObjectDump()
- {
- $oErr = new DatabaseError('Sql error', 123, null, array('one' => 'two'));
- $this->assertStringContainsString('two', $oErr->getSqlDebugDump());
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/DebugHtml.php');
-
-class DebugTest extends \PHPUnit\Framework\TestCase
-{
-
- protected function setUp(): void
- {
- $this->oWithDebuginfo = $this->getMockBuilder(\GeococdeMock::class)
- ->setMethods(array('debugInfo'))
- ->getMock();
- $this->oWithDebuginfo->method('debugInfo')
- ->willReturn(array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'));
-
-
- $this->oWithToString = $this->getMockBuilder(\SomeMock::class)
- ->setMethods(array('__toString'))
- ->getMock();
- $this->oWithToString->method('__toString')->willReturn('me as string');
- }
-
- public function testPrintVar()
- {
- $this->expectOutputString(<<<EOT
-<pre><b>Var0:</b> </pre>
-<pre><b>Var1:</b> <i>True</i></pre>
-<pre><b>Var2:</b> <i>False</i></pre>
-<pre><b>Var3:</b> 0</pre>
-<pre><b>Var4:</b> 'String'</pre>
-<pre><b>Var5:</b> 0 => 'one'
- 1 => 'two'
- 2 => 'three'</pre>
-<pre><b>Var6:</b> 'key' => 'value'
- 'key2' => 'value2'</pre>
-<pre><b>Var7:</b> me as string</pre>
-<pre><b>Var8:</b> 'value', 'value2'</pre>
-
-EOT
- );
-
- Debug::printVar('Var0', null);
- Debug::printVar('Var1', true);
- Debug::printVar('Var2', false);
- Debug::printVar('Var3', 0);
- Debug::printVar('Var4', 'String');
- Debug::printVar('Var5', array('one', 'two', 'three'));
- Debug::printVar('Var6', array('key' => 'value', 'key2' => 'value2'));
- Debug::printVar('Var7', $this->oWithToString);
- Debug::printVar('Var8', Debug::fmtArrayVals(array('key' => 'value', 'key2' => 'value2')));
- }
-
-
- public function testDebugArray()
- {
- $this->expectOutputString(<<<EOT
-<pre><b>Arr0:</b> 'null'</pre>
-<pre><b>Arr1:</b> 'key1' => 'val1'
- 'key2' => 'val2'
- 'key3' => 'val3'</pre>
-
-EOT
- );
-
- Debug::printDebugArray('Arr0', null);
- Debug::printDebugArray('Arr1', $this->oWithDebuginfo);
- }
-
-
- public function testPrintDebugTable()
- {
- $this->expectOutputString(<<<EOT
-<b>Table1:</b>
-<table border='1'>
-</table>
-<b>Table2:</b>
-<table border='1'>
-</table>
-<b>Table3:</b>
-<table border='1'>
- <tr>
- <th><small>0</small></th>
- <th><small>1</small></th>
- </tr>
- <tr>
- <td><pre>'one'</pre></td>
- <td><pre>'two'</pre></td>
- </tr>
- <tr>
- <td><pre>'three'</pre></td>
- <td><pre>'four'</pre></td>
- </tr>
-</table>
-<b>Table4:</b>
-<table border='1'>
- <tr>
- <th><small>key1</small></th>
- <th><small>key2</small></th>
- <th><small>key3</small></th>
- </tr>
- <tr>
- <td><pre>'val1'</pre></td>
- <td><pre>'val2'</pre></td>
- <td><pre>'val3'</pre></td>
- </tr>
-</table>
-
-EOT
- );
-
- Debug::printDebugTable('Table1', null);
-
- Debug::printDebugTable('Table2', array());
-
- // Numeric headers
- Debug::printDebugTable('Table3', array(array('one', 'two'), array('three', 'four')));
-
- // Associate array
- Debug::printDebugTable('Table4', array($this->oWithDebuginfo));
- }
-
- public function testPrintGroupTable()
- {
- $this->expectOutputString(<<<EOT
-<b>Table1:</b>
-<table border='1'>
-</table>
-<b>Table2:</b>
-<table border='1'>
-</table>
-<b>Table3:</b>
-<table border='1'>
- <tr>
- <th><small>Group</small></th>
- <th><small>key1</small></th>
- <th><small>key2</small></th>
- </tr>
- <tr>
- <td><pre>group1</pre></td>
- <td><pre>'val1'</pre></td>
- <td><pre>'val2'</pre></td>
- </tr>
- <tr>
- <td><pre>group1</pre></td>
- <td><pre>'one'</pre></td>
- <td><pre>'two'</pre></td>
- </tr>
- <tr>
- <td><pre>group2</pre></td>
- <td><pre>'val1'</pre></td>
- <td><pre>'val2'</pre></td>
- </tr>
-</table>
-<b>Table4:</b>
-<table border='1'>
- <tr>
- <th><small>Group</small></th>
- <th><small>key1</small></th>
- <th><small>key2</small></th>
- <th><small>key3</small></th>
- </tr>
- <tr>
- <td><pre>group1</pre></td>
- <td><pre>'val1'</pre></td>
- <td><pre>'val2'</pre></td>
- <td><pre>'val3'</pre></td>
- </tr>
- <tr>
- <td><pre>group1</pre></td>
- <td><pre>'val1'</pre></td>
- <td><pre>'val2'</pre></td>
- <td><pre>'val3'</pre></td>
- </tr>
-</table>
-
-EOT
- );
-
- Debug::printGroupTable('Table1', null);
- Debug::printGroupTable('Table2', array());
-
- // header are taken from first group item, thus no key3 gets printed
- $aGroups = array(
- 'group1' => array(
- array('key1' => 'val1', 'key2' => 'val2'),
- array('key1' => 'one', 'key2' => 'two', 'unknown' => 1),
- ),
- 'group2' => array(
- array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'),
- )
- );
- Debug::printGroupTable('Table3', $aGroups);
-
- $aGroups = array(
- 'group1' => array($this->oWithDebuginfo, $this->oWithDebuginfo),
- );
- Debug::printGroupTable('Table4', $aGroups);
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/lib.php');
-require_once(CONST_LibDir.'/ClassTypes.php');
-
-class LibTest extends \PHPUnit\Framework\TestCase
-{
-
- public function testAddQuotes()
- {
- // FIXME: not quoting existing quote signs is probably a bug
- $this->assertSame("'St. John's'", addQuotes("St. John's"));
- $this->assertSame("''", addQuotes(''));
- }
-
- public function testParseLatLon()
- {
- // no coordinates expected
- $this->assertFalse(parseLatLon(''));
- $this->assertFalse(parseLatLon('abc'));
- $this->assertFalse(parseLatLon('12 34'));
-
- // coordinates expected
- $this->assertNotNull(parseLatLon('0.0 -0.0'));
-
- $aRes = parseLatLon(' abc 12.456 -78.90 def ');
- $this->assertEquals($aRes[1], 12.456);
- $this->assertEquals($aRes[2], -78.90);
- $this->assertEquals($aRes[0], ' 12.456 -78.90 ');
-
- $aRes = parseLatLon(' [12.456,-78.90] ');
- $this->assertEquals($aRes[1], 12.456);
- $this->assertEquals($aRes[2], -78.90);
- $this->assertEquals($aRes[0], ' [12.456,-78.90] ');
-
- $aRes = parseLatLon(' -12.456,-78.90 ');
- $this->assertEquals($aRes[1], -12.456);
- $this->assertEquals($aRes[2], -78.90);
- $this->assertEquals($aRes[0], ' -12.456,-78.90 ');
-
- // http://en.wikipedia.org/wiki/Geographic_coordinate_conversion
- // these all represent the same location
- $aQueries = array(
- '40 26.767 N 79 58.933 W',
- '40° 26.767′ N 79° 58.933′ W',
- "40° 26.767' N 79° 58.933' W",
- "40° 26.767'
- N 79° 58.933' W",
- 'N 40 26.767, W 79 58.933',
- 'N 40°26.767′, W 79°58.933′',
- ' N 40°26.767′, W 79°58.933′',
- "N 40°26.767', W 79°58.933'",
-
- '40 26 46 N 79 58 56 W',
- '40° 26′ 46″ N 79° 58′ 56″ W',
- '40° 26′ 46.00″ N 79° 58′ 56.00″ W',
- '40°26′46″N 79°58′56″W',
- 'N 40 26 46 W 79 58 56',
- 'N 40° 26′ 46″, W 79° 58′ 56″',
- 'N 40° 26\' 46", W 79° 58\' 56"',
- 'N 40° 26\' 46", W 79° 58\' 56"',
-
- '40.446 -79.982',
- '40.446,-79.982',
- '40.446° N 79.982° W',
- 'N 40.446° W 79.982°',
-
- '[40.446 -79.982]',
- '[40.446,\v-79.982]',
- ' 40.446 , -79.982 ',
- ' 40.446 , -79.982 ',
- ' 40.446 , -79.982 ',
- ' 40.446\v, -79.982 ',
- );
-
-
- foreach ($aQueries as $sQuery) {
- $aRes = parseLatLon($sQuery);
- $this->assertEqualsWithDelta(40.446, $aRes[1], 0.01, 'degrees decimal ' . $sQuery);
- $this->assertEqualsWithDelta(-79.982, $aRes[2], 0.01, 'degrees decimal ' . $sQuery);
- $this->assertEquals($sQuery, $aRes[0]);
- }
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/ParameterParser.php');
-
-
-function userError($sError)
-{
- throw new \Exception($sError);
-}
-
-class ParameterParserTest extends \PHPUnit\Framework\TestCase
-{
-
-
- public function testGetBool()
- {
- $oParams = new ParameterParser(array(
- 'bool1' => '1',
- 'bool2' => '0',
- 'bool3' => 'true',
- 'bool4' => 'false',
- 'bool5' => ''
- ));
-
- $this->assertSame(false, $oParams->getBool('non-exists'));
- $this->assertSame(true, $oParams->getBool('non-exists', true));
- $this->assertSame(true, $oParams->getBool('bool1'));
- $this->assertSame(false, $oParams->getBool('bool2'));
- $this->assertSame(true, $oParams->getBool('bool3'));
- $this->assertSame(true, $oParams->getBool('bool4'));
- $this->assertSame(false, $oParams->getBool('bool5'));
- }
-
-
- public function testGetInt()
- {
- $oParams = new ParameterParser(array(
- 'int1' => '5',
- 'int2' => '-1',
- 'int3' => 0
- ));
-
- $this->assertSame(false, $oParams->getInt('non-exists'));
- $this->assertSame(999, $oParams->getInt('non-exists', 999));
- $this->assertSame(5, $oParams->getInt('int1'));
-
- $this->assertSame(-1, $oParams->getInt('int2'));
- $this->assertSame(0, $oParams->getInt('int3'));
- }
-
-
- public function testGetIntWithNonNumber()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage("Integer number expected for parameter 'int4'");
-
- (new ParameterParser(array('int4' => 'a')))->getInt('int4');
- }
-
-
- public function testGetIntWithEmpytString()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage("Integer number expected for parameter 'int5'");
-
- (new ParameterParser(array('int5' => '')))->getInt('int5');
- }
-
-
- public function testGetFloat()
- {
-
- $oParams = new ParameterParser(array(
- 'float1' => '1.0',
- 'float2' => '-5',
- 'float3' => 0
- ));
-
- $this->assertSame(false, $oParams->getFloat('non-exists'));
- $this->assertSame(999, $oParams->getFloat('non-exists', 999));
- $this->assertSame(1.0, $oParams->getFloat('float1'));
- $this->assertSame(-5.0, $oParams->getFloat('float2'));
- $this->assertSame(0.0, $oParams->getFloat('float3'));
- }
-
- public function testGetFloatWithEmptyString()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage("Floating-point number expected for parameter 'float4'");
-
- (new ParameterParser(array('float4' => '')))->getFloat('float4');
- }
-
- public function testGetFloatWithTextString()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage("Floating-point number expected for parameter 'float5'");
-
- (new ParameterParser(array('float5' => 'a')))->getFloat('float5');
- }
-
-
- public function testGetFloatWithInvalidNumber()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage("Floating-point number expected for parameter 'float6'");
-
- (new ParameterParser(array('float6' => '-55.')))->getFloat('float6');
- }
-
-
- public function testGetString()
- {
- $oParams = new ParameterParser(array(
- 'str1' => 'abc',
- 'str2' => '',
- 'str3' => '0'
- ));
-
- $this->assertSame(false, $oParams->getString('non-exists'));
- $this->assertSame('default', $oParams->getString('non-exists', 'default'));
- $this->assertSame('abc', $oParams->getString('str1'));
- $this->assertSame(false, $oParams->getStringList('str2'));
- $this->assertSame(false, $oParams->getStringList('str3')); // sadly PHP magic treats 0 as false when returned
- }
-
-
- public function testGetSet()
- {
- $oParams = new ParameterParser(array(
- 'val1' => 'foo',
- 'val2' => '',
- 'val3' => 0
- ));
-
- $this->assertSame(false, $oParams->getSet('non-exists', array('foo', 'bar')));
- $this->assertSame('default', $oParams->getSet('non-exists', array('foo', 'bar'), 'default'));
- $this->assertSame('foo', $oParams->getSet('val1', array('foo', 'bar')));
-
- $this->assertSame(false, $oParams->getSet('val2', array('foo', 'bar')));
- $this->assertSame(false, $oParams->getSet('val3', array('foo', 'bar')));
- }
-
-
- public function testGetSetWithValueNotInSet()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage("Parameter 'val4' must be one of: foo, bar");
-
- (new ParameterParser(array('val4' => 'faz')))->getSet('val4', array('foo', 'bar'));
- }
-
-
- public function testGetStringList()
- {
- $oParams = new ParameterParser(array(
- 'list1' => ',a,b,c,,c,d',
- 'list2' => 'a',
- 'list3' => '',
- 'list4' => '0'
- ));
-
- $this->assertSame(false, $oParams->getStringList('non-exists'));
- $this->assertSame(array('a', 'b'), $oParams->getStringList('non-exists', array('a', 'b')));
- $this->assertSame(array('a', 'b', 'c', 'c', 'd'), $oParams->getStringList('list1'));
- $this->assertSame(array('a'), $oParams->getStringList('list2'));
- $this->assertSame(false, $oParams->getStringList('list3'));
- $this->assertSame(false, $oParams->getStringList('list4'));
- }
-
-
- public function testGetPreferredLanguages()
- {
- $oParams = new ParameterParser(array('accept-language' => ''));
- $this->assertSame(array(
- 'name:default' => 'name:default',
- '_place_name:default' => '_place_name:default',
- 'name' => 'name',
- '_place_name' => '_place_name'
- ), array_slice($oParams->getPreferredLanguages('default'), 0, 4));
-
- $oParams = new ParameterParser(array('accept-language' => 'de,en'));
- $this->assertSame(array(
- 'name:de' => 'name:de',
- '_place_name:de' => '_place_name:de',
- 'name:en' => 'name:en',
- '_place_name:en' => '_place_name:en',
- 'name' => 'name',
- '_place_name' => '_place_name'
- ), array_slice($oParams->getPreferredLanguages('default'), 0, 6));
-
- $oParams = new ParameterParser(array('accept-language' => 'fr-ca,fr;q=0.8,en-ca;q=0.5,en;q=0.3'));
- $this->assertSame(array(
- 'name:fr-ca' => 'name:fr-ca',
- '_place_name:fr-ca' => '_place_name:fr-ca',
- 'name:fr' => 'name:fr',
- '_place_name:fr' => '_place_name:fr',
- 'name:en-ca' => 'name:en-ca',
- '_place_name:en-ca' => '_place_name:en-ca',
- 'name:en' => 'name:en',
- '_place_name:en' => '_place_name:en',
- 'name' => 'name',
- '_place_name' => '_place_name'
- ), array_slice($oParams->getPreferredLanguages('default'), 0, 10));
-
- $oParams = new ParameterParser(array('accept-language' => 'ja_rm,zh_pinyin'));
- $this->assertSame(array(
- 'name:ja_rm' => 'name:ja_rm',
- '_place_name:ja_rm' => '_place_name:ja_rm',
- 'name:zh_pinyin' => 'name:zh_pinyin',
- '_place_name:zh_pinyin' => '_place_name:zh_pinyin',
- 'name:ja' => 'name:ja',
- '_place_name:ja' => '_place_name:ja',
- 'name:zh' => 'name:zh',
- '_place_name:zh' => '_place_name:zh',
- 'name' => 'name',
- '_place_name' => '_place_name'
- ), array_slice($oParams->getPreferredLanguages('default'), 0, 10));
- }
-
- public function testHasSetAny()
- {
- $oParams = new ParameterParser(array(
- 'one' => '',
- 'two' => 0,
- 'three' => '0',
- 'four' => '1',
- 'five' => 'anystring'
- ));
- $this->assertFalse($oParams->hasSetAny(array()));
- $this->assertFalse($oParams->hasSetAny(array('')));
- $this->assertFalse($oParams->hasSetAny(array('unknown')));
- $this->assertFalse($oParams->hasSetAny(array('one', 'two', 'three')));
- $this->assertTrue($oParams->hasSetAny(array('one', 'four')));
- $this->assertTrue($oParams->hasSetAny(array('four')));
- $this->assertTrue($oParams->hasSetAny(array('five')));
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/Result.php');
-
-function mkRankedResult($iId, $iResultRank)
-{
- $oResult = new Result($iId);
- $oResult->iResultRank = $iResultRank;
-
- return $oResult;
-}
-
-
-class ResultTest extends \PHPUnit\Framework\TestCase
-{
- public function testSplitResults()
- {
- $aSplitResults = Result::splitResults(array(
- mkRankedResult(1, 2),
- mkRankedResult(2, 0),
- mkRankedResult(3, 0),
- mkRankedResult(4, 2),
- mkRankedResult(5, 1)
- ));
-
-
- $aHead = array_keys($aSplitResults['head']);
- $aTail = array_keys($aSplitResults['tail']);
-
- $this->assertEquals($aHead, array(2, 3));
- $this->assertEquals($aTail, array(1, 4, 5));
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/SearchContext.php');
-
-class SearchContextTest extends \PHPUnit\Framework\TestCase
-{
- private $oCtx;
-
-
- protected function setUp(): void
- {
- $this->oCtx = new SearchContext();
- }
-
- public function testHasNearPoint()
- {
- $this->assertFalse($this->oCtx->hasNearPoint());
- $this->oCtx->setNearPoint(0, 0);
- $this->assertTrue($this->oCtx->hasNearPoint());
- }
-
- public function testNearRadius()
- {
- $this->oCtx->setNearPoint(1, 1);
- $this->assertEquals(0.1, $this->oCtx->nearRadius());
- $this->oCtx->setNearPoint(1, 1, 0.338);
- $this->assertEquals(0.338, $this->oCtx->nearRadius());
- }
-
- public function testWithinSQL()
- {
- $this->oCtx->setNearPoint(0.1, 23, 1);
-
- $this->assertEquals(
- 'ST_DWithin(foo, ST_SetSRID(ST_Point(23,0.1),4326), 1.000000)',
- $this->oCtx->withinSQL('foo')
- );
- }
-
- public function testDistanceSQL()
- {
- $this->oCtx->setNearPoint(0.1, 23, 1);
-
- $this->assertEquals(
- 'ST_Distance(ST_SetSRID(ST_Point(23,0.1),4326), foo)',
- $this->oCtx->distanceSQL('foo')
- );
- }
-
- public function testSetViewboxFromBox()
- {
- $viewbox = array(30, 20, 40, 50);
- $this->oCtx->setViewboxFromBox($viewbox, true);
- $this->assertEquals(
- 'ST_SetSRID(ST_MakeBox2D(ST_Point(30.000000,20.000000),ST_Point(40.000000,50.000000)),4326)',
- $this->oCtx->sqlViewboxSmall
- );
- // height: 10
- // width: 30
- $this->assertEquals(
- 'ST_SetSRID(ST_MakeBox2D(ST_Point(50.000000,80.000000),ST_Point(20.000000,-10.000000)),4326)',
- $this->oCtx->sqlViewboxLarge
- );
-
-
- $viewbox = array(-1.5, -2, 1.5, 2);
- $this->oCtx->setViewboxFromBox($viewbox, true);
- $this->assertEquals(
- 'ST_SetSRID(ST_MakeBox2D(ST_Point(-1.500000,-2.000000),ST_Point(1.500000,2.000000)),4326)',
- $this->oCtx->sqlViewboxSmall
- );
- // height: 3
- // width: 4
- $this->assertEquals(
- 'ST_SetSRID(ST_MakeBox2D(ST_Point(4.500000,6.000000),ST_Point(-4.500000,-6.000000)),4326)',
- $this->oCtx->sqlViewboxLarge
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/Shell.php');
-
-class ShellTest extends \PHPUnit\Framework\TestCase
-{
- public function testNew()
- {
- $this->expectException('ArgumentCountError');
- $this->expectExceptionMessage('Too few arguments to function');
- $oCmd = new \Nominatim\Shell();
-
-
- $oCmd = new \Nominatim\Shell('wc', '-l', 'file.txt');
- $this->assertSame(
- "wc -l 'file.txt'",
- $oCmd->escapedCmd()
- );
- }
-
- public function testaddParams()
- {
- $oCmd = new \Nominatim\Shell('grep');
- $oCmd->addParams('-a', 'abc')
- ->addParams(10);
-
- $this->assertSame(
- 'grep -a abc 10',
- $oCmd->escapedCmd(),
- 'no escaping needed, chained'
- );
-
- $oCmd = new \Nominatim\Shell('grep');
- $oCmd->addParams();
- $oCmd->addParams(null);
- $oCmd->addParams('');
-
- $this->assertEmpty($oCmd->aParams);
- $this->assertSame('grep', $oCmd->escapedCmd(), 'empty params');
-
- $oCmd = new \Nominatim\Shell('echo', '-n', 0);
- $this->assertSame(
- 'echo -n 0',
- $oCmd->escapedCmd(),
- 'zero param'
- );
-
- $oCmd = new \Nominatim\Shell('/path with space/do.php');
- $oCmd->addParams('-a', ' b ');
- $oCmd->addParams('--flag');
- $oCmd->addParams('two words');
- $oCmd->addParams('v=1');
-
- $this->assertSame(
- "'/path with space/do.php' -a ' b ' --flag 'two words' 'v=1'",
- $oCmd->escapedCmd(),
- 'escape whitespace'
- );
-
- $oCmd = new \Nominatim\Shell('grep');
- $oCmd->addParams(';', '|more&', '2>&1');
-
- $this->assertSame(
- "grep ';' '|more&' '2>&1'",
- $oCmd->escapedCmd(),
- 'escape shell characters'
- );
- }
-
- public function testaddEnvPair()
- {
- $oCmd = new \Nominatim\Shell('date');
-
- $oCmd->addEnvPair('one', 'two words')
- ->addEnvPair('null', null)
- ->addEnvPair(null, 'null')
- ->addEnvPair('empty', '')
- ->addEnvPair('', 'empty');
-
- $this->assertEquals(
- array('one' => 'two words', 'empty' => ''),
- $oCmd->aEnv
- );
-
- $oCmd->addEnvPair('one', 'overwrite');
- $this->assertEquals(
- array('one' => 'overwrite', 'empty' => ''),
- $oCmd->aEnv
- );
- }
-
- public function testClone()
- {
- $oCmd = new \Nominatim\Shell('wc', '-l', 'file.txt');
- $oCmd2 = clone $oCmd;
- $oCmd->addParams('--flag');
- $oCmd2->addParams('--flag2');
-
- $this->assertSame(
- "wc -l 'file.txt' --flag",
- $oCmd->escapedCmd()
- );
-
- $this->assertSame(
- "wc -l 'file.txt' --flag2",
- $oCmd2->escapedCmd()
- );
- }
-
- public function testRun()
- {
- $oCmd = new \Nominatim\Shell('echo');
-
- $this->assertSame(0, $oCmd->run());
-
- // var_dump($sStdout);
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/SimpleWordList.php');
-
-class TokensFullSet
-{
- public function containsAny($sTerm)
- {
- return true;
- }
-}
-
-// phpcs:ignore PSR1.Classes.ClassDeclaration.MultipleClasses
-class TokensPartialSet
-{
- public function __construct($aTokens)
- {
- $this->aTokens = array_flip($aTokens);
- }
-
- public function containsAny($sTerm)
- {
- return isset($this->aTokens[$sTerm]);
- }
-}
-
-// phpcs:ignore PSR1.Classes.ClassDeclaration.MultipleClasses
-class SimpleWordListTest extends \PHPUnit\Framework\TestCase
-{
-
-
- private function serializeSets($aSets)
- {
- $aParts = array();
- foreach ($aSets as $aSet) {
- $aParts[] = '(' . join('|', $aSet) . ')';
- }
- return join(',', $aParts);
- }
-
-
- public function testEmptyPhrase()
- {
- $oList = new SimpleWordList('');
- $this->assertNull($oList->getWordSets(new TokensFullSet()));
- }
-
-
- public function testSingleWordPhrase()
- {
- $oList = new SimpleWordList('a');
-
- $this->assertEquals(
- '(a)',
- $this->serializeSets($oList->getWordSets(new TokensFullSet()))
- );
- }
-
-
- public function testMultiWordPhrase()
- {
- $oList = new SimpleWordList('a b');
- $this->assertEquals(
- '(a b),(a|b)',
- $this->serializeSets($oList->getWordSets(new TokensFullSet()))
- );
-
- $oList = new SimpleWordList('a b c');
- $this->assertEquals(
- '(a b c),(a b|c),(a|b c),(a|b|c)',
- $this->serializeSets($oList->getWordSets(new TokensFullSet()))
- );
-
- $oList = new SimpleWordList('a b c d');
- $this->assertEquals(
- '(a b c d),(a b c|d),(a b|c d),(a|b c d),(a b|c|d),(a|b c|d),(a|b|c d),(a|b|c|d)',
- $this->serializeSets($oList->getWordSets(new TokensFullSet()))
- );
- }
-
- public function testCmpByArraylen()
- {
- // Array elements are phrases, we want to sort so longest phrases are first
- $aList1 = array('hackney', 'bridge', 'london', 'england');
- $aList2 = array('hackney', 'london', 'bridge');
- $aList3 = array('bridge', 'hackney', 'london', 'england');
-
- $this->assertEquals(0, \Nominatim\SimpleWordList::cmpByArraylen($aList1, $aList1));
-
- // list2 "wins". Less array elements
- $this->assertEquals(1, \Nominatim\SimpleWordList::cmpByArraylen($aList1, $aList2));
- $this->assertEquals(-1, \Nominatim\SimpleWordList::cmpByArraylen($aList2, $aList3));
-
- // list1 "wins". Same number of array elements but longer first element
- $this->assertEquals(-1, \Nominatim\SimpleWordList::cmpByArraylen($aList1, $aList3));
- }
-
- public function testMaxWordSets()
- {
- $aWords = array_fill(0, 4, 'a');
- $oList = new SimpleWordList(join(' ', $aWords));
- $this->assertEquals(8, count($oList->getWordSets(new TokensFullSet())));
-
- $aWords = array_fill(0, 18, 'a');
- $oList = new SimpleWordList(join(' ', $aWords));
- $this->assertEquals(100, count($oList->getWordSets(new TokensFullSet())));
- }
-
-
- public function testPartialTokensShortTerm()
- {
- $oList = new SimpleWordList('a b c d');
- $this->assertEquals(
- '(a|b c d),(a|b c|d)',
- $this->serializeSets($oList->getWordSets(new TokensPartialSet(array('a', 'b', 'd', 'b c', 'b c d'))))
- );
- }
-
-
- public function testPartialTokensLongTerm()
- {
- $aWords = array_fill(0, 18, 'a');
- $oList = new SimpleWordList(join(' ', $aWords));
- $this->assertEquals(80, count($oList->getWordSets(new TokensPartialSet(array('a', 'a a a a a')))));
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-@define('CONST_TokenizerDir', dirname(__FILE__));
-
-require_once(CONST_LibDir.'/DB.php');
-require_once(CONST_LibDir.'/Status.php');
-
-
-class StatusTest extends \PHPUnit\Framework\TestCase
-{
-
- public function testNoDatabaseGiven()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage('No database');
- $this->expectExceptionCode(700);
-
- $oDB = null;
- $oStatus = new Status($oDB);
- $this->assertEquals('No database', $oStatus->status());
- }
-
- public function testNoDatabaseConnectionFail()
- {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage('Database connection failed');
- $this->expectExceptionCode(700);
-
- $oDbStub = $this->getMockBuilder(Nominatim\DB::class)
- ->setMethods(array('connect'))
- ->getMock();
-
- $oDbStub->method('connect')
- ->will($this->returnCallback(function () {
- throw new \Nominatim\DatabaseError('psql connection problem', 500, null, 'unknown database');
- }));
-
-
- $oStatus = new Status($oDbStub);
- $this->assertEquals('No database', $oStatus->status());
- }
-
- public function testOK()
- {
- $oDbStub = $this->getMockBuilder(Nominatim\DB::class)
- ->setMethods(array('connect', 'getOne'))
- ->getMock();
-
- $oDbStub->method('getOne')
- ->will($this->returnCallback(function ($sql) {
- if (preg_match("/make_standard_name\('(\w+)'\)/", $sql, $aMatch)) return $aMatch[1];
- if (preg_match('/SELECT word_id, word_token/', $sql)) return 1234;
- }));
-
- $oStatus = new Status($oDbStub);
- $this->assertNull($oStatus->status());
- }
-
- public function testDataDate()
- {
- $oDbStub = $this->getMockBuilder(Nominatim\DB::class)
- ->setMethods(array('getOne'))
- ->getMock();
-
- $oDbStub->method('getOne')
- ->willReturn(1519430221);
-
- $oStatus = new Status($oDbStub);
- $this->assertEquals(1519430221, $oStatus->dataDate());
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-require_once(CONST_LibDir.'/TokenList.php');
-
-
-class TokenListTest extends \PHPUnit\Framework\TestCase
-{
- protected function setUp(): void
- {
- $this->oNormalizer = $this->getMockBuilder(\MockNormalizer::class)
- ->setMethods(array('transliterate'))
- ->getMock();
- $this->oNormalizer->method('transliterate')
- ->will($this->returnCallback(function ($text) {
- return strtolower($text);
- }));
- }
-
- private function wordResult($aFields)
- {
- $aRow = array(
- 'word_id' => null,
- 'word_token' => null,
- 'word' => null,
- 'class' => null,
- 'type' => null,
- 'country_code' => null,
- 'count' => 0
- );
- return array_merge($aRow, $aFields);
- }
-
- public function testList()
- {
- $TL = new TokenList;
-
- $this->assertEquals(0, $TL->count());
-
- $TL->addToken('word1', 'token1');
- $TL->addToken('word1', 'token2');
-
- $this->assertEquals(1, $TL->count());
-
- $this->assertTrue($TL->contains('word1'));
- $this->assertEquals(array('token1', 'token2'), $TL->get('word1'));
-
- $this->assertFalse($TL->contains('unknownword'));
- $this->assertEquals(array(), $TL->get('unknownword'));
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
-
-namespace Nominatim;
-
-class Tokenizer
-{
- private $oDB;
-
- public function __construct(&$oDB)
- {
- $this->oDB =& $oDB;
- }
-
- public function checkStatus()
- {
- }
-}
+++ /dev/null
-<?php
-/**
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * This file is part of Nominatim. (https://nominatim.org)
- *
- * Copyright (C) 2022 by the Nominatim developer community.
- * For a full list of authors see the git log.
- */
- @define('CONST_LibDir', '../../lib-php');
- @define('CONST_DataDir', '../..');
-
- @define('CONST_Debug', true);
- @define('CONST_NoAccessControl', false);
+++ /dev/null
-[{"place_id":194663412,
- "osm_type":null,
- "osm_id":null,
- "name":{"name": "10 Downing Street", "name:en": "10 Downing Street", "name:es": "10 de Downing Street", "name:he": "דאונינג 10", "name:ko": "다우닝 가 10번지", "name:zh": "唐寧街10號"},
- "class":"tourism",
- "type":"attraction",
- "admin_level":null,
- "fromarea":true,
- "isaddress":true,
- "rank_address":29,
- "distance":0,
- "localname":"10 Downing Street"},
-{"place_id":194663412,
- "osm_type":null,
- "osm_id":null,
- "name":{"ref": "10"},
- "class":"place",
- "type":"house_number",
- "admin_level":null,
- "fromarea":true,
- "isaddress":true,
- "rank_address":28,
- "distance":0,
- "localname":"10"},
-{"place_id":68310941,
- "osm_type":"W",
- "osm_id":4244999,
- "name":{"name": "Downing Street"},
- "class":"highway",
- "type":"residential",
- "admin_level":15,
- "fromarea":true,
- "isaddress":true,
- "rank_address":26,
- "distance":0,
- "localname":"Downing Street"},
-{"place_id":16037318,
- "osm_type":"N",
- "osm_id":1653239257,
- "name":{"name": "St. James's"},
- "class":"place",
- "type":"neighbourhood",
- "admin_level":15,
- "fromarea":true,
- "isaddress":true,
- "rank_address":22,
- "distance":0.00982435489434447,
- "localname":"St. James's"},
-{"place_id":51691981,
- "osm_type":"N",
- "osm_id":3937587633,
- "name":{"name": "St Clement Danes"},
- "class":"place",
- "type":"neighbourhood",
- "admin_level":15,
- "fromarea":true,
- "isaddress":false,
- "rank_address":22,
- "distance":0.0128768181947227,
- "localname":"St Clement Danes"},
-{"place_id":22208313,
- "osm_type":"N",
- "osm_id":2290086954,
- "name":{"name": "Covent Garden"},
- "class":"place",
- "type":"suburb",
- "admin_level":15,
- "fromarea":true,
- "isaddress":true,
- "rank_address":20,
- "distance":0.00935748249317067,
- "localname":"Covent Garden"},
-{"place_id":21742712,
- "osm_type":"N",
- "osm_id":2288030397,
- "name":{"name": "Millbank"},
- "class":"place",
- "type":"suburb",
- "admin_level":15,
- "fromarea":true,
- "isaddress":false,
- "rank_address":20,
- "distance":0.0106525181285902,
- "localname":"Millbank"},
-{"place_id":122775,
- "osm_type":"N",
- "osm_id":26745371,
- "name":{"name": "St Giles"},
- "class":"place",
- "type":"suburb",
- "admin_level":15,
- "fromarea":true,
- "isaddress":false,
- "rank_address":20,
- "distance":0.0136188357358441,
- "localname":"St Giles"},
-{"place_id":134882,
- "osm_type":"N",
- "osm_id":27553719,
- "name":{"name": "Lambeth"},
- "class":"place",
- "type":"suburb",
- "admin_level":15,
- "fromarea":true,
- "isaddress":false,
- "rank_address":20,
- "distance":0.0093308163978298,
- "localname":"Lambeth"},
-{"place_id":194276676,
- "osm_type":"R",
- "osm_id":51781,
- "name":{"name": "City of Westminster", "name:be": "Вэстмінстэр", "name:cy": "San Steffan", "name:en": "Westminster", "name:he": "וסטמינסטר", "name:ru": "Вестминстер"},
- "class":"place",
- "type":"city",
- "admin_level":8,
- "fromarea":true,
- "isaddress":true,
- "rank_address":16,
- "distance":0.0340909562148044,
- "localname":"Westminster"},
-{"place_id":195398522,
- "osm_type":"N",
- "osm_id":107775,
- "name":{"name": "London", "name:ab": "Лондан", "name:af": "Londen", "name:am": "ለንደን", "name:an": "Londres", "name:ar": "لندن", "name:ba": "Лондон", "name:be": "Лондан", "name:bg": "Лондон", "name:bn": "লন্ডন", "name:bo": "ལོན་ཊོན།", "name:br": "Londrez", "name:ca": "Londres", "name:co": "Londra", "name:cs": "Londýn", "name:cu": "Лондонъ", "name:cv": "Лондон", "name:cy": "Llundain", "name:de": "London", "name:el": "Λονδίνο", "name:en": "London", "name:eo": "Londono", "name:es": "Londres", "name:eu": "Londres", "name:fa": "لندن", "name:fi": "Lontoo", "name:fr": "Londres", "name:fy": "Londen", "name:ga": "Londain", "name:gd": "Lunnainn", "name:gl": "Londres - London", "name:gn": "Londye", "name:gu": "લંડન", "name:gv": "Lunnin", "name:he": "לונדון", "name:hi": "लंदन", "name:ht": "Lonn", "name:hu": "London", "name:hy": "Լոնդոն", "name:is": "Lundúnir", "name:it": "Londra", "name:ja": "ロンドン", "name:ka": "ლონდონი", "name:kk": "Лондон", "name:kn": "ಲಂಡನ್", "name:ko": "런던", "name:ku": "London", "name:kv": "Лондон", "name:kw": "Loundres", "name:ky": "Лондон", "name:la": "Londinium", "name:li": "Londe", "name:ln": "Londoni", "name:lo": "ລອນດອນ", "name:lt": "Londonas", "name:lv": "Londona", "name:mi": "Rānana", "name:mk": "Лондон", "name:ml": "ലണ്ടൻ", "name:mn": "Лондон", "name:mr": "लंडन", "name:mt": "Londra", "name:my": "လန်ဒန်မြို့", "name:ne": "लण्डन", "name:nl": "Londen", "name:no": "London", "name:oc": "Londres", "name:or": "ଲଣ୍ଡନ", "name:os": "Лондон", "name:pl": "Londyn", "name:ps": "لندن", "name:pt": "Londres", "name:rm": "Londra", "name:ro": "Londra", "name:ru": "Лондон", "name:sa": "लन्डन्", "name:sc": "Londra", "name:si": "ලන්ඩන්", "name:sk": "Londýn", "name:sq": "Londra", "name:sr": "Лондон", "name:sv": "London", "name:ta": "இலண்டன்", "name:te": "లండన్", "name:tg": "Лондон", "name:th": "ลอนดอน", "name:tl": "Londres", "name:tr": "Londra", "name:tt": "Лондон", "name:uk": "Лондон", "name:ur": "لندن", "name:vi": "Luân Đôn", "name:wo": "Londar", "name:yi": "לאנדאן", "name:yo": "Lọndọnu", "name:zh": "倫敦", "name:zu": "ILondon", "name:ang": "Lunden", "name:arc": "ܠܘܢܕܘܢ", "name:arz": "لندن", "name:ast": "Londres", "name:bcl": "Londres", "name:cdo": "Lùng-dŭng", "name:ckb": "لەندەن", "name:diq": "Londra", "name:eml": "Lòndra", "name:ext": "Londri", "name:frp": "Londres", "name:gan": "倫敦", "name:haw": "Lākana", "name:ilo": "Londres", "name:jbo": "london", "name:koi": "Лондон", "name:krc": "Лондон", "name:lad": "Londra", "name:lbe": "Лондон", "name:lez": "Лондон", "name:lij": "Londra", "name:lmo": "Lundra", "name:mhr": "Лондон", "name:mrj": "Лондон", "name:mwl": "Londres", "name:mzn": "لندن", "name:nah": "Londres", "name:nap": "Londra", "name:new": "लण्डन", "name:nrm": "Londres", "name:pcd": "Londe", "name:pms": "Londra", "name:pnb": "لندن", "name:pnt": "Λονδίνο", "name:rue": "Лондон", "name:sah": "Лондон", "name:scn": "Londra", "name:sco": "Lunnon", "name:szl": "Lůndůn", "name:tet": "Londres", "name:tpi": "Landen", "name:tzl": "Londra", "name:udm": "Лондон", "name:vec": "Łondra", "name:vls": "Londn", "name:wuu": "伦敦", "name:xmf": "ლონდონი", "name:yue": "倫敦", "name:zea": "Londen", "name:nds-nl": "Londen", "name:bat-smg": "Londons", "name:roa-rup": "Londra", "name:roa-tara": "Londre", "name:be-tarask": "Лёндан", "name:zh_pinyin": "Lúndūn", "name:zh-classical": "倫敦", "name:zh-simplified": "伦敦", "name:zh-traditional": "倫敦"},
- "class":"place",
- "type":"city",
- "admin_level":2,
- "fromarea":true,
- "isaddress":false,
- "rank_address":16,
- "distance":0.00412384196971048,
- "localname":"London"},
-{"place_id":193774423,
- "osm_type":"R",
- "osm_id":65606,
- "name":{"name": "London", "ISO3166-2": "GB-LND", "name:be": "Лондан", "name:ca": "Londres", "name:el": "Λονδίνο", "name:en": "London", "name:eo": "Londono", "name:es": "Londres", "name:fa": "لندن", "name:fi": "Lontoo", "name:fr": "Londres", "name:fy": "Londen", "name:gl": "Londres", "name:hi": "लंदन", "name:lt": "Londonas", "name:nl": "Londen", "name:pl": "Londyn", "name:pt": "Londres", "name:ru": "Лондон", "name:uk": "Лондон", "name:vi": "Luân Đôn", "name:zh": "伦敦", "int_name": "London", "name:szl": "Lůndůn", "name:tzl": "Londra", "name:be-tarask": "Лёндан"},
- "class":"place",
- "type":"city",
- "admin_level":6,
- "fromarea":true,
- "isaddress":true,
- "rank_address":12,
- "distance":0.0172243361058611,
- "localname":"London"},
-{"place_id":194000080,
- "osm_type":"R",
- "osm_id":175342,
- "name":{"name": "Greater London", "name:be": "Вялікі Лондан", "name:de": "Groß-London", "name:en": "Greater London", "name:fr": "Grand Londres", "name:lt": "Didysis Londonas", "name:ru": "Большой Лондон", "name:uk": "Великий Лондон", "official_name": "Greater London (incl. City of London)", "name:be-tarask": "Вялікі Лёндан"},
- "class":"boundary",
- "type":"administrative",
- "admin_level":5,
- "fromarea":true,
- "isaddress":true,
- "rank_address":10,
- "distance":0.0172532381571105,
- "localname":"Greater London"},
-{"place_id":194325361,
- "osm_type":"R",
- "osm_id":58447,
- "name":{"ref": "ENG", "ISO3166-2": "GB-ENG", "name": "England", "name:be": "Англія", "name:br": "Bro-Saoz", "name:ca": "Anglaterra", "name:cs": "Anglie", "name:cy": "Lloegr", "name:de": "England", "name:el": "Αγγλία", "name:en": "England", "name:eo": "Anglujo", "name:es": "Inglaterra", "name:fi": "Englanti", "name:fr": "Angleterre", "name:fy": "Ingelân", "name:ga": "Sasana", "name:gd": "Sasainn", "name:gv": "Sostyn", "name:he": "אנגליה", "name:hu": "Anglia", "name:ia": "Anglaterra", "name:io": "Anglia", "name:it": "Inghilterra", "name:la": "Anglia", "name:lt": "Anglija", "name:nl": "Engeland", "name:pl": "Anglia", "name:pt": "Inglaterra", "name:ru": "Англия", "name:sk": "Anglicko", "name:sv": "England", "name:tr": "İngiltere", "name:uk": "Англія", "name:vi": "Anh", "name:vo": "Linglän", "name:zh": "英格蘭", "name:hsb": "Jendźelska", "name:nds": "England", "name:tok": "ma Inli", "name:tzl": "Anglatzara", "alt_name:eo": "Anglio", "alt_name:ia": "Anglia", "old_name:vi": "Anh Quốc", "alt_name:nds": "Ingland", "name:be-tarask": "Ангельшчына", "name:zh-classical": "英格蘭", "name:zh-simplified": "英格兰", "name:zh-traditional": "英格蘭"},
- "class":"boundary",
- "type":"administrative",
- "admin_level":4,
- "fromarea":true,
- "isaddress":true,
- "rank_address":8,
- "distance":1.75192967136328,
- "localname":"England"},
-{"place_id":null,
- "osm_type":null,
- "osm_id":null,
- "name":{"ref": "SW1A 2AA"},
- "class":"place",
- "type":"postcode",
- "admin_level":null,
- "fromarea":true,
- "isaddress":true,
- "rank_address":5,
- "distance":0,
- "localname":"SW1A 2AA"},
-{"place_id":40715006,
- "osm_type":"N",
- "osm_id":3055075992,
- "name":{"ref": "SW1A 2AQ"},
- "class":"place",
- "type":"postcode",
- "admin_level":15,
- "fromarea":true,
- "isaddress":false,
- "rank_address":5,
- "distance":0.00172905579146705,
- "localname":"SW1A 2AQ"},
-{"place_id":194354400,
- "osm_type":"R",
- "osm_id":62149,
- "name":{"name": "United Kingdom", "name:ab": "Британиа Ду", "name:af": "Verenigde Koninkryk", "name:ak": "United Kingdom", "name:am": "ዩናይትድ ኪንግደም", "name:an": "Reino Unito", "name:ar": "المملكة المتحدة", "name:az": "Böyük Britaniya", "name:ba": "Бөйөк Британия", "name:be": "Вялікабрытанія", "name:bg": "Обединено кралство Великобритания и Северна Ирландия", "name:bi": "Unaeted Kingdom", "name:bm": "Angilɛtɛri", "name:bn": "যুক্তরাজ্য", "name:bo": "དབྱིན་ཇི་མཉམ་འབྲེལ།", "name:br": "Rouantelezh-Unanet", "name:bs": "Ujedinjeno Kraljevstvo Velike Britanije i Sjeverne Irske", "name:ca": "Regne Unit", "name:ce": "Йоккха Британи", "name:co": "Regnu Unitu", "name:cs": "Spojené království", "name:cu": "Вєлика Британїꙗ", "name:cv": "Аслă Британи", "name:cy": "Deyrnas Unedig", "name:da": "Storbritannien", "name:de": "Vereinigtes Königreich", "name:dv": "ޔުނައިޓެޑް ކިންގްޑަމް", "name:dz": "ཡུ་ནའི་ཊེཊ་ཀིང་ཌམ", "name:ee": "United Kingdom", "name:el": "Ηνωμένο Βασίλειο", "name:en": "United Kingdom", "name:eo": "Britujo", "name:es": "Reino Unido", "name:et": "Suurbritannia", "name:eu": "Erresuma Batua", "name:fa": "بریتانیا", "name:ff": "Laamateeri Rentundi", "name:fi": "Yhdistynyt kuningaskunta", "name:fo": "Stóra Bretland", "name:fr": "Royaume-Uni", "name:fy": "Feriene Keninkryk", "name:ga": "An Ríocht Aontaithe", "name:gd": "An Rìoghachd Aonaichte", "name:gl": "Reino Unido", "name:gn": "Tavetã Joaju", "name:gu": "યુનાઇટેડ કિંગડમ", "name:gv": "Reeriaght Unnaneysit", "name:ha": "Birtaniya", "name:he": "הממלכה המאוחדת", "name:hi": "यूनाइटेड किंगडम", "name:hr": "Ujedinjeno Kraljevstvo", "name:ht": "Wayòm Ini", "name:hu": "Egyesült Királyság", "name:hy": "Միացյալ Թագավորություն", "name:ia": "Regno Unite", "name:id": "Britania Raya", "name:ie": "Reyatu Unit", "name:ig": "Obodoézè Nà Ofú", "name:ii": "ꑱꇩ", "name:io": "Unionita Rejio", "name:is": "Bretland", "name:it": "Regno Unito", "name:ja": "イギリス", "name:jv": "Britania Raya", "name:ka": "გაერთიანებული სამეფო", "name:kg": "Royaume-Uni", "name:ki": "Ngeretha", "name:kk": "Ұлыбритания", "name:kl": "Tuluit Nunaat", "name:km": "រាជាណាចក្ររួម", "name:kn": "ಯುನೈಟೆಡ್ ಕಿಂಗ್ಡಂ", "name:ko": "영국", "name:ks": "یُنایٹِڑ کِنٛگڈَم", "name:ku": "Keyaniya Yekbûyî", "name:kv": "Ыджыд Британия", "name:kw": "Ruwvaneth Unys", "name:ky": "Улуу Британия жана Түндүк Ирландия", "name:la": "Britanniarum Regnum", "name:lb": "Groussbritannien an Nordirland", "name:lg": "Bungereza", "name:li": "Vereineg Keuninkriek", "name:ln": "Ingɛlɛ́tɛlɛ", "name:lo": "ສະຫະລາດຊະອານາຈັກ", "name:lt": "Jungtinė Karalystė", "name:lv": "Apvienotā Karaliste", "name:mg": "Fanjakana Mitambatra", "name:mi": "Kīngitanga Kotahi", "name:mk": "Обединето Кралство", "name:ml": "യുണൈറ്റഡ് കിങ്ഡം", "name:mn": "Их Британи", "name:mr": "युनायटेड किंग्डम", "name:ms": "United Kingdom", "name:mt": "Renju Unit", "name:my": "ယူနိုက်တက်ကင်းဒမ်းနိုင်ငံ", "name:na": "Ingerand", "name:ne": "संयुक्त अधिराज्य", "name:nl": "Verenigd Koninkrijk", "name:nn": "Storbritannia", "name:no": "Storbritannia", "name:nv": "Tótaʼ Dinéʼiʼ Bikéyah", "name:oc": "Reialme Unit", "name:or": "ଯୁକ୍ତରାଜ୍ୟ", "name:os": "Стыр Британи", "name:pa": "ਸੰਯੁਕਤ ਬਾਦਸ਼ਾਹੀ", "name:pl": "Wielka Brytania", "name:ps": "بريتانيا", "name:pt": "Reino Unido", "name:qu": "Hukllachasqa Qhapaq Suyu", "name:rm": "Reginavel Unì", "name:rn": "Ubwongereza", "name:ro": "Regatul Unit al Marii Britanii și al Irlandei de Nord", "name:ru": "Великобритания", "name:rw": "Ubwongereza", "name:sa": "संयुक्त अधिराज्य", "name:sc": "Rennu Auniadu", "name:se": "Ovttastuvvan gonagasriika", "name:sg": "Ködörögbïä--Ôko", "name:sh": "Ujedinjeno Kraljevstvo", "name:si": "එක්සත් රාජධානිය", "name:sk": "Spojené kráľovstvo", "name:sl": "Združeno kraljestvo Velike Britanije in Severne Irske", "name:sn": "United Kingdom", "name:so": "Midowga boqortooyada Britan", "name:sq": "Mbretëria e Bashkuar e Britanisë dhe Irlandës së Veriut", "name:sr": "Уједињено Краљевство", "name:ss": "United Kingdom", "name:su": "Britania", "name:sv": "Storbritannien", "name:sw": "Ufalme wa Muungano", "name:ta": "ஐக்கிய இராச்சியம்", "name:te": "యునైటెడ్ కింగ్డమ్", "name:tg": "Подшоҳии Муттаҳида", "name:th": "สหราชอาณาจักร", "name:ti": "እንግሊዝ", "name:tl": "Nagkakaisang Kaharian", "name:to": "Pilitānia", "name:tr": "Birleşik Krallık", "name:tt": "Бөекбритания", "name:tw": "United Kingdom", "name:ty": "Paratāne", "name:ug": "بۈيۈك بېرىتانىيە", "name:uk": "Велика Британія", "name:ur": "برطانیہ", "name:uz": "Birlashgan Qirollik", "name:vi": "Vương quốc Anh", "name:vo": "Regän Pebalöl", "name:wo": "Nguur-Yu-Bennoo", "name:yi": "פאראייניגטע קעניגרייך", "name:yo": "Ilẹ̀ọba Aṣọ̀kan", "name:za": "Yinghgoz", "name:zh": "英國", "name:zu": "Umbuso Ohlangeneyo", "alt_name": "United Kingdom; UK; Britain; Great Britain", "int_name": "United Kingdom", "name:als": "Vereinigtes Königreich", "name:ang": "Geāned Cynerīce", "name:arc": "ܡܠܟܘܬܐ ܡܚܝܕܬܐ", "name:arz": "المملكه المتحده", "name:ast": "Reinu Xuníu", "name:bar": "Vaeinigts Kinireich", "name:bcl": "Reyno Unido", "name:bjn": "Britania Raya", "name:bpy": "তিলপারাজ্য", "name:bug": "United Kingdom", "name:bxr": "Нэгдсэн Вант Улс", "name:cdo": "Ĭng-guók", "name:ceb": "Hiniusang Gingharian", "name:chr": "ᎡᎵᏏᎯ", "name:chy": "United Kingdom", "name:ckb": "شانشینی یەکگرتوو", "name:crh": "Büyük Britaniya", "name:csb": "Wiôlgô Britanijô", "name:diq": "Qraliya Yewbiyayiye", "name:dsb": "Wjelika Britaniska", "name:eml": "Régn Unî", "name:ext": "Réinu Uniu", "name:frp": "Royômo-Uni", "name:frr": "Feriind Kiningrik", "name:fur": "Ream Unît", "name:gag": "Büük Britaniya", "name:gan": "英國", "name:hak": "Yîn-koet", "name:haw": "Aupuni Mōʻī Hui Pū ʻia", "name:hif": "United Kingdom", "name:hsb": "Zjednoćene kralestwo", "name:ilo": "Nagkaykaysa a Pagarian", "name:jbo": "ritygu'e", "name:kab": "Legliz", "name:kbd": "Британиэшхуэ", "name:koi": "Ыджыт Бритму", "name:krc": "Уллу Британия", "name:ksh": "Jrußbritannie", "name:lad": "Reyno Unido", "name:lez": "ЧIехибритания", "name:lfn": "Rena Unida", "name:lij": "Regno Unïo", "name:lmo": "Regn Ünì", "name:ltg": "Lelbrytaneja", "name:mhr": "Ушымо Королевстве", "name:mrj": "Кого Британи", "name:mwl": "Reino Ounido", "name:mzn": "بریتانیا", "name:nah": "Tlacetilīlli Huēyitlahtohcāyōtl", "name:nap": "Gran Vretagna", "name:nds": "Vereenigt Königriek vun Grootbritannien un Noordirland", "name:nov": "Unionati Regia", "name:nrm": "Rouoyaume Unni", "name:pag": "Reino Unido", "name:pam": "Pisanmetung a Ka-arian", "name:pap": "Reino Uni", "name:pcd": "Roéyôme-Uni", "name:pih": "Yunitid Kingdum", "name:pms": "Regn Unì", "name:pnb": "برطانیہ", "name:pnt": "Ηνωμένο Βασίλειο", "name:rmy": "Phandlo Thagaripen la Bare Britaniyako thai le Nordutne Irlandesko", "name:rue": "Велика Брітанія", "name:sah": "Холбоhуктаах Хоруоллук", "name:scn": "Regnu Unitu", "name:sco": "Unitit Kinrick", "name:srn": "Ingriskondre", "name:stq": "Fereeniged Köönichriek fon Groot-Britannien un Noudirlound", "name:szl": "Wjelgo Brytańijo", "name:tet": "Reinu Naklibur", "name:tok": "ma Juke", "name:tpi": "Yunaitet Kingdom", "name:tzl": "Regipäts Viensiçat", "name:udm": "Великобритания", "name:vec": "Regno Unìo", "name:vep": "Sur' Britanii", "name:vls": "Verênigd Keunienkryk", "name:war": "Reino Unido", "name:wuu": "英国", "name:xal": "Ик Бритишин болн Ар Гәәлгүдин Ниицәтә Нутг", "name:xmf": "გოართოიანაფილი ომაფე", "name:yue": "英國", "name:zea": "Vereênigd Konienkriek", "name:zh_py": "Yingguo", "short_name": "UK", "alt_name:eo": "Britio", "alt_name:sr": "УК;У.К.", "alt_name:vi": "Vương quốc Liên hiệp Anh", "name:nds-nl": "Verienigd Keuninkriek", "name:zh_pyt": "Yīngguó", "name:bat-smg": "Jongtėnė Karalīstė", "name:cbk-zam": "Reinos Unidos de Gran Britania y Norte Irelandia", "name:fiu-vro": "Ütiskuningriik", "name:roa-rup": "Britania Mari", "name:roa-tara": "Regne Aunìte", "official_name": "United Kingdom of Great Britain and Northern Ireland", "short_name:el": "ΗΒ", "short_name:vo": "Britän", "name:be-tarask": "Вялікабрытанія", "name:zh-min-nan": "Liân-ha̍p Ông-kok", "official_name:be": "Злучанае Каралеўства Вялікабрытаніі і Паўночнай Ірландыі", "official_name:br": "Rouantelezh Unanet Breizh-Veur ha Norzhiwerzhon", "official_name:ca": "Regne Unit de Gran Bretanya i Irlanda del Nord", "official_name:cs": "Spojené království Velké Británie a Severního Irska", "official_name:de": "Vereinigtes Königreich Großbritannien und Nordirland", "official_name:el": "Ηνωμένο Βασίλειο της Μεγάλης Βρετανίας και της Βόρειας Ιρλανδίας", "official_name:en": "United Kingdom of Great Britain and Northern Ireland", "official_name:eo": "Unuiĝinta Reĝlando de Granda Britujo kaj Nord-Irlando", "official_name:es": "Reino Unido de Gran Bretaña", "official_name:et": "Suurbritannia ja Põhja-Iiri Ühendkuningriik", "official_name:fr": "Royaume-Uni de Grande-Bretagne et d'Irlande du Nord", "official_name:hr": "Ujedinjeno Kraljevstvo Velike Britanije i Sjeverne Irske", "official_name:id": "Perserikatan Kerajaan Britania Raya dan Irlandia Utara", "official_name:it": "Regno Unito di Gran Bretagna e Irlanda del Nord", "official_name:ja": "グレートブリテン及び北アイルランド連合王国", "official_name:ku": "Keyaniya Yekbûyî ya Brîtaniya Mezin û Bakurê Îrlandê", "official_name:lb": "Vereenegt Kinnekräich vu Groussbritannien an Nordirland", "official_name:no": "Det forente kongeriket Storbritannia og Nord-Irland", "official_name:pl": "Zjednoczone Królestwo Wielkiej Brytanii i Irlandii Północnej", "official_name:pt": "Reino Unido da Grã-Bretanha e Irlanda do Norte", "official_name:ru": "Соединённое королевство Великобритании и Северной Ирландии", "official_name:sk": "Spojené kráľovstvo Veľkej Británie a Severného Írska", "official_name:sl": "Združeno kraljestvo Velike Britanije in Severne Irske", "official_name:sr": "Уједињено Краљевство Велике Британије и Северне Ирске", "official_name:sv": "Förenade konungariket Storbritannien och Nordirland", "official_name:vi": "Vương quốc Liên hiệp Anh và Bắc Ireland", "name:abbreviation": "UK", "name:zh-classical": "英國", "official_name:scn": "Regnu Unitu di Gran Britagna e Irlanna dû Nord", "name:zh-simplified": "英国", "name:zh-traditional": "英國"},
- "class":"place",
- "type":"country",
- "admin_level":2,
- "fromarea":true,
- "isaddress":true,
- "rank_address":4,
- "distance":4.56060933645498,
- "localname":"United Kingdom"},
-{"place_id":null,
- "osm_type":null,
- "osm_id":null,
- "name":{"ref": "gb"},
- "class":"place",
- "type":"country_code",
- "admin_level":null,
- "fromarea":true,
- "isaddress":false,
- "rank_address":4,
- "distance":0,
- "localname":"gb"}
-]
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- backupGlobals="false"
- backupStaticAttributes="false"
- colors="true"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- processIsolation="false"
- stopOnFailure="false"
- bootstrap="./bootstrap.php"
- beStrictAboutTestsThatDoNotTestAnything="true"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
- <coverage>
- <include>
- <directory>../../lib-php/</directory>
- </include>
- </coverage>
- <php>
- </php>
- <testsuites>
- <testsuite name="Nominatim PHP Test Suite">
- <directory>./Nominatim</directory>
- </testsuite>
- </testsuites>
-</phpunit>