]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/LocationTest.php
AtomPub tetss: confirming edit URL linked properly in individual entry return
[quix0rs-gnu-social.git] / tests / LocationTest.php
1 <?php
2
3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4     print "This script must be run from the command line\n";
5     exit();
6 }
7
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('STATUSNET', true);
10
11 require_once INSTALLDIR . '/lib/common.php';
12
13 // Make sure this is loaded
14 // XXX: how to test other plugins...?
15
16 addPlugin('Geonames');
17
18 class LocationTest extends PHPUnit_Framework_TestCase
19 {
20
21     /**
22      * @dataProvider locationNames
23      */
24
25     public function testLocationFromName($name, $language, $location)
26     {
27         $result = Location::fromName($name, $language);
28         $this->assertEquals($result, $location);
29     }
30
31     static public function locationNames()
32     {
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));
37     }
38
39     /**
40      * @dataProvider locationIds
41      */
42
43     public function testLocationFromId($id, $ns, $language, $location)
44     {
45         $result = Location::fromId($id, $ns, $language);
46         $this->assertEquals($result, $location);
47     }
48
49     static public function locationIds()
50     {
51         return array(array(6077243, GeonamesPlugin::LOCATION_NS, 'en', null),
52                      array(5391959, GeonamesPlugin::LOCATION_NS, 'en', null));
53     }
54
55     /**
56      * @dataProvider locationLatLons
57      */
58
59     public function testLocationFromLatLon($lat, $lon, $language, $location)
60     {
61         $result = Location::fromLatLon($lat, $lon, $language);
62         $this->assertEquals($result, $location);
63     }
64
65     static public function locationLatLons()
66     {
67         return array(array(37.77493, -122.41942, 'en', null),
68                      array(45.509, -73.588, 'en', null));
69     }
70
71     /**
72      * @dataProvider nameOfLocation
73      */
74
75     public function testLocationGetName($location, $language, $name)
76     {
77         $result = $location->getName($language);
78         $this->assertEquals($result, $name);
79     }
80
81     static public function nameOfLocation()
82     {
83         return array(array(new Location(), 'en', 'Montreal'),
84                      array(new Location(), 'fr', 'MontrĂ©al'));
85     }
86 }
87