This test directory is sturctured as follows:
+```
-+- bdd Functional API tests
| \
| +- steps Step implementations for test descriptions
+- php PHP unit tests
+- scenes Geometry test data
+- testdb Base data for generating API test database
-
+```
PHP Unit Tests
==============
To execute the test suite run
- cd test/php
- phpunit ../
+ cd test/php
+ phpunit ../
It will read phpunit.xml which points to the library, test path, bootstrap
strip and set other parameters.
These tests are meant to test the different API endpoints and their parameters.
They require a preimported test database, which consists of the import of a
-planet extract. The polygons defining the extract can be found in the test/testdb
+planet extract. A precompiled PBF with the necessary data can be downloaded from
+http://www.nominatim.org/data/test/nominatim-api-testdata.pbf
+
+The polygons defining the extract can be found in the test/testdb
directory. There is also a reduced set of wikipedia data for this extract,
which you need to import as well. For Tiger tests the data of South Dakota
is required. Get the Tiger files `46*`.
$bDidSomething = true;
$oDB =& getDB();
if (!pg_query($oDB->connection, 'DELETE from placex where osm_type=\'P\'')) fail(pg_last_error($oDB->connection));
- $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,country_code,geometry) ";
- $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,country_code,";
- $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from (select country_code,postcode,";
+ $sSQL = "insert into placex (osm_type,osm_id,class,type,address,country_code,geometry) ";
+ $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',";
+ $sSQL .= "hstore('postcode', pc),country_code,";
+ $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from (select country_code,";
+ $sSQL .= "address->'postcode' as pc,";
$sSQL .= "avg(st_x(st_centroid(geometry))) as x,avg(st_y(st_centroid(geometry))) as y ";
- $sSQL .= "from placex where postcode is not null group by country_code,postcode) as x ";
+ $sSQL .= "from placex where address ? 'postcode' group by country_code,pc) as x ";
$sSQL .= "where ST_Point(x,y) is not null";
if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
if (CONST_Use_Extra_US_Postcodes) {
- $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,country_code,geometry) ";
- $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,'us',";
+ $sSQL = "insert into placex (osm_type,osm_id,class,type,address,country_code,geometry) ";
+ $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',";
+ $sSQL .= "hstore('postcode', postcode),'us',";
$sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from us_postcode";
if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection));
}