summaryrefslogtreecommitdiff
path: root/tests/HashTagDetectionTests.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-08-26 21:56:59 -0400
committerCraig Andrews <candrews@integralblue.com>2009-08-26 21:56:59 -0400
commit3e362233ee2f7acd676c0ee86025d7511f265b7e (patch)
treef691c476d17d31517e3367c1bc3d9608c4d7eed8 /tests/HashTagDetectionTests.php
parent504c42aa7d4ff5cccd722bceb3231a5a8f46a27b (diff)
parentb7beac36c2dbebfa27982b2fc6c82cf2ebbaae8d (diff)
Merge commit 'laconica/0.8.x' into 0.9.x
Diffstat (limited to 'tests/HashTagDetectionTests.php')
-rw-r--r--tests/HashTagDetectionTests.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/HashTagDetectionTests.php b/tests/HashTagDetectionTests.php
new file mode 100644
index 000000000..283226bd4
--- /dev/null
+++ b/tests/HashTagDetectionTests.php
@@ -0,0 +1,47 @@
+<?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('LACONICA', true);
+
+require_once INSTALLDIR . '/lib/common.php';
+
+class HashTagDetectionTests extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider provider
+ *
+ */
+ public function testProduction($content, $expected)
+ {
+ $rendered = common_render_text($content);
+ $this->assertEquals($expected, $rendered);
+ }
+
+ static public function provider()
+ {
+ return array(
+ array('hello',
+ 'hello'),
+ array('#hello people',
+ '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span> people'),
+ array('"#hello" people',
+ '&quot;#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>&quot; people'),
+ array('say "#hello" people',
+ 'say &quot;#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>&quot; people'),
+ array('say (#hello) people',
+ 'say (#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>) people'),
+ array('say [#hello] people',
+ 'say [#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>] people'),
+ array('say {#hello} people',
+ 'say {#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>} people'),
+ array('say \'#hello\' people',
+ 'say \'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>\' people'),
+ );
+ }
+}
+