summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-01 13:04:23 -0500
committerEvan Prodromou <evan@status.net>2009-11-01 13:04:23 -0500
commit5f5413624d166a9b2116d266c7698dd6dcd2d8c4 (patch)
tree3f7f85bbfb747d68bf518df026eea6ac686ad0c0 /tests
parent658683e240ef6e44c6450a16448fe7cb82f792f2 (diff)
parent44ce8e2fcd1eba0d0f2723c246c1a021614e2763 (diff)
Merge branch '0.9.x' into userflag
Diffstat (limited to 'tests')
-rw-r--r--tests/LocationTest.php87
-rw-r--r--tests/URLDetectionTest.php6
2 files changed, 92 insertions, 1 deletions
diff --git a/tests/LocationTest.php b/tests/LocationTest.php
new file mode 100644
index 000000000..62849eb9f
--- /dev/null
+++ b/tests/LocationTest.php
@@ -0,0 +1,87 @@
+<?php
+
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('STATUSNET', true);
+
+require_once INSTALLDIR . '/lib/common.php';
+
+// Make sure this is loaded
+// XXX: how to test other plugins...?
+
+addPlugin('Geonames');
+
+class LocationTest extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @dataProvider locationNames
+ */
+
+ 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));
+ }
+
+ /**
+ * @dataProvider locationIds
+ */
+
+ 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::NAMESPACE, 'en', null),
+ array(5391959, GeonamesPlugin::NAMESPACE, 'en', null));
+ }
+
+ /**
+ * @dataProvider locationLatLons
+ */
+
+ public function testLocationFromLatLon($lat, $lon, $language, $location)
+ {
+ $result = Location::fromLatLon($lat, $lon, $language);
+ $this->assertEquals($result, $location);
+ }
+
+ static public function locationLatLons()
+ {
+ return array(array(37.77493, -122.41942, 'en', null),
+ array(45.509, -73.588, 'en', null));
+ }
+
+ /**
+ * @dataProvider nameOfLocation
+ */
+
+ public function testLocationGetName($location, $language, $name)
+ {
+ $result = $location->getName($language);
+ $this->assertEquals($result, $name);
+ }
+
+ static public function nameOfLocation()
+ {
+ return array(array(new Location(), 'en', 'Montreal'),
+ array(new Location(), 'fr', 'Montréal'));
+ }
+}
+
diff --git a/tests/URLDetectionTest.php b/tests/URLDetectionTest.php
index 45203bf6e..0cc03ccce 100644
--- a/tests/URLDetectionTest.php
+++ b/tests/URLDetectionTest.php
@@ -47,7 +47,9 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
array('127.0.0.1/\'test',
'<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
array('127.0.0.1/"test',
- '<a href="http://127.0.0.1/&quot;test" title="http://127.0.0.1/&quot;test" rel="external">127.0.0.1/&quot;test</a>'),
+ '<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1/</a>&quot;test'),
+ array('127.0.0.1/test"test',
+ '<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="external">127.0.0.1/test</a>&quot;test'),
array('127.0.0.1/-test',
'<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
array('127.0.0.1/_test',
@@ -170,6 +172,8 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
'\'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>\''),
array('"http://example.com"',
'&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>&quot;'),
+ array('"http://example.com/"',
+ '&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>&quot;'),
array('http://example.com',
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
array('(http://example.com)',