3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4 print "This script must be run from the command line\n";
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('GNUSOCIAL', true);
10 define('STATUSNET', true); // compatibility
12 require_once INSTALLDIR . '/lib/common.php';
14 // Make sure this is loaded
15 // XXX: how to test other plugins...?
17 addPlugin('Geonames');
19 class LocationTest extends PHPUnit_Framework_TestCase
23 * @dataProvider locationNames
26 public function testLocationFromName($name, $language, $location)
28 $result = Location::fromName($name, $language);
29 $this->assertEquals($result, $location);
32 static public function locationNames()
34 return array(array('Montreal', 'en', null),
35 array('San Francisco, CA', 'en', null),
36 array('Paris, France', 'en', null),
37 array('Paris, Texas', 'en', null));
41 * @dataProvider locationIds
44 public function testLocationFromId($id, $ns, $language, $location)
46 $result = Location::fromId($id, $ns, $language);
47 $this->assertEquals($result, $location);
50 static public function locationIds()
52 return array(array(6077243, GeonamesPlugin::LOCATION_NS, 'en', null),
53 array(5391959, GeonamesPlugin::LOCATION_NS, 'en', null));
57 * @dataProvider locationLatLons
60 public function testLocationFromLatLon($lat, $lon, $language, $location)
62 $result = Location::fromLatLon($lat, $lon, $language);
63 $this->assertEquals($result, $location);
66 static public function locationLatLons()
68 return array(array(37.77493, -122.41942, 'en', null),
69 array(45.509, -73.588, 'en', null));
73 * @dataProvider nameOfLocation
76 public function testLocationGetName($location, $language, $name)
78 $result = $location->getName($language);
79 $this->assertEquals($result, $name);
82 static public function nameOfLocation()
84 return array(array(new Location(), 'en', 'Montreal'),
85 array(new Location(), 'fr', 'Montréal'));