2009-08-24 23:33:16 +01:00
|
|
|
<?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__) . '/..'));
|
2009-08-25 23:42:34 +01:00
|
|
|
define('STATUSNET', true);
|
2009-08-24 23:33:16 +01:00
|
|
|
|
|
|
|
require_once INSTALLDIR . '/lib/common.php';
|
|
|
|
|
|
|
|
class HashTagDetectionTest 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'),
|
2009-08-25 22:52:16 +01:00
|
|
|
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'),
|
2009-08-24 23:33:16 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|