summaryrefslogtreecommitdiff
path: root/tests/HashTagDetectionTests.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-08-27 14:52:32 -0700
committerEvan Prodromou <evan@status.net>2009-08-27 14:52:32 -0700
commita08c76a4342cfb4b3d772f6880ba0b8f3153b246 (patch)
treee2ba9ef2f670d01cf700a732d36050fe3ce63774 /tests/HashTagDetectionTests.php
parent522008dee570aafcc844bf123d25203c7d9c3ebc (diff)
parenteb667d09d9c6ef5a1465a5f8d824661a9387a4da (diff)
Merge branch '0.9.x' of git@gitorious.org:laconica/mainline into 0.9.x
Conflicts: classes/laconica.ini
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..aeac4a5e3
--- /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('STATUSNET', 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'),
+ );
+ }
+}
+