. namespace Tests\Unit; if (!defined('INSTALLDIR')) { define('INSTALLDIR', dirname(dirname(__DIR__))); } if (!defined('PUBLICDIR')) { define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); } if (!defined('GNUSOCIAL')) { define('GNUSOCIAL', true); } if (!defined('STATUSNET')) { // Compatibility define('STATUSNET', true); } use PHPUnit\Framework\TestCase; require_once INSTALLDIR . '/lib/util/common.php'; final class HashTagDetectionTests extends TestCase { /** * @dataProvider provider * * @param $content * @param $expected */ public function testProduction($content, $expected) { $rendered = common_render_text($content); static::assertSame($expected, $rendered); } public static function provider() { return [ ['hello', 'hello',], ['#hello people', '# people',], ['"#hello" people', '"#" people',], ['say "#hello" people', 'say "#" people',], ['say (#hello) people', 'say (#) people',], ['say [#hello] people', 'say [#] people',], ['say {#hello} people', 'say {#} people',], ['say \'#hello\' people', 'say \'#\' people',], // Unicode legit letters ['#éclair yummy', '# yummy',], ['#维基百科 zh.wikipedia!', '# zh.wikipedia!',], ['#Россия russia', '# russia',], // Unicode punctuators -- the ideographic "," separates the tag, just as "," does ['#维基百科,zh.wikipedia!', '#,zh.wikipedia!',], ['#维基百科,zh.wikipedia!', '#,zh.wikipedia!',], ]; } }