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('STATUSNET', true);
11 require_once INSTALLDIR . '/lib/common.php';
13 // Make sure this is loaded
14 // XXX: how to test other plugins...?
16 addPlugin('Geonames');
18 class LocationTest extends PHPUnit_Framework_TestCase
22 * @dataProvider locationNames
25 public function testLocationFromName($name, $language, $location)
27 $result = Location::fromName($name, $language);
28 $this->assertEquals($result, $location);
31 static public function locationNames()
33 return array(array('Montreal', 'en', null),
34 array('San Francisco, CA', 'en', null),
35 array('Paris, France', 'en', null),
36 array('Paris, Texas', 'en', null));
40 * @dataProvider locationIds
43 public function testLocationFromId($id, $ns, $language, $location)
45 $result = Location::fromId($id, $ns, $language);
46 $this->assertEquals($result, $location);
49 static public function locationIds()
51 return array(array(6077243, GeonamesPlugin::LOCATION_NS, 'en', null),
52 array(5391959, GeonamesPlugin::LOCATION_NS, 'en', null));
56 * @dataProvider locationLatLons
59 public function testLocationFromLatLon($lat, $lon, $language, $location)
61 $result = Location::fromLatLon($lat, $lon, $language);
62 $this->assertEquals($result, $location);
65 static public function locationLatLons()
67 return array(array(37.77493, -122.41942, 'en', null),
68 array(45.509, -73.588, 'en', null));
72 * @dataProvider nameOfLocation
75 public function testLocationGetName($location, $language, $name)
77 $result = $location->getName($language);
78 $this->assertEquals($result, $name);
81 static public function nameOfLocation()
83 return array(array(new Location(), 'en', 'Montreal'),
84 array(new Location(), 'fr', 'Montréal'));