diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-08-26 14:35:25 +0000 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-08-26 14:35:25 +0000 |
commit | 937a05fb5d043ee6c2ce0e2d668c93f8b6717bc9 (patch) | |
tree | 4d32a6f2fa4ff1722831cf97b4a833d71ca2506e /tests/HashTagDetectionTests.php | |
parent | cbdf8e51aa2826e11cc17c34bcbf568ca37e26ce (diff) | |
parent | 2f1e719cbee6734053c70845665204ee1899c88e (diff) |
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
Diffstat (limited to 'tests/HashTagDetectionTests.php')
-rw-r--r-- | tests/HashTagDetectionTests.php | 47 |
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', + '"#<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'), + 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'), + ); + } +} + |