123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace Tests\Unit;
- if (!defined('INSTALLDIR')) {
- define('INSTALLDIR', dirname(dirname(__DIR__)));
- }
- if (!defined('PUBLICDIR')) {
- define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
- }
- if (!defined('GNUSOCIAL')) {
- define('GNUSOCIAL', true);
- }
- if (!defined('STATUSNET')) {
- define('STATUSNET', true);
- }
- use GeonamesPlugin;
- use Location;
- use PHPUnit\Framework\TestCase;
- require_once INSTALLDIR . '/lib/util/common.php';
- addPlugin('Geonames');
- final class LocationTest extends TestCase
- {
-
- public function testLocationFromName($name, $language, $location)
- {
- $result = Location::fromName($name, $language);
- $this->assertEquals($result, $location);
- }
- static public function locationNames()
- {
- return array(array('Montreal', 'en', null),
- array('San Francisco, CA', 'en', null),
- array('Paris, France', 'en', null),
- array('Paris, Texas', 'en', null));
- }
-
- public function testLocationFromId($id, $ns, $language, $location)
- {
- $result = Location::fromId($id, $ns, $language);
- $this->assertEquals($result, $location);
- }
- static public function locationIds()
- {
- return array(array(6077243, GeonamesPlugin::LOCATION_NS, 'en', null),
- array(5391959, GeonamesPlugin::LOCATION_NS, 'en', null));
- }
-
- public function testLocationFromLatLon($lat, $lon, $language, $location)
- {
- $result = Location::fromLatLon($lat, $lon, $language);
- $this->assertEquals($location, $result->location_id);
- }
- static public function locationLatLons()
- {
- return array(array(37.77493, -122.41942, 'en', null),
- array(45.509, -73.588, 'en', null));
- }
-
- public function testLocationGetName($location, $language, $name)
- {
- $result = empty($location) ? null : $location->getName($language);
- $this->assertEquals($name, $result);
- }
- static public function nameOfLocation()
- {
- $loc = Location::fromName('Montreal', 'en');
- return array(array($loc, 'en', null),
- array($loc, 'fr', null));
- }
- }
|