]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/HashTagDetectionTests.php
Introduced common_location_shared() to check if location sharing is always,
[quix0rs-gnu-social.git] / tests / HashTagDetectionTests.php
1 <?php
2
3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4     print "This script must be run from the command line\n";
5     exit();
6 }
7
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('GNUSOCIAL', true);
10 define('STATUSNET', true);  // compatibility
11
12 require_once INSTALLDIR . '/lib/common.php';
13
14 class HashTagDetectionTests extends PHPUnit_Framework_TestCase
15 {
16     /**
17      * @dataProvider provider
18      *
19      */
20     public function testProduction($content, $expected)
21     {
22         $rendered = common_render_text($content);
23         $this->assertEquals($expected, $rendered);
24     }
25
26     static public function provider()
27     {
28         return array(
29                      array('hello',
30                            'hello'),
31                      array('#hello people',
32                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span> people'),
33                      array('"#hello" people',
34                            '&quot;#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>&quot; people'),
35                      array('say "#hello" people',
36                            'say &quot;#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>&quot; people'),
37                      array('say (#hello) people',
38                            'say (#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>) people'),
39                      array('say [#hello] people',
40                            'say [#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>] people'),
41                      array('say {#hello} people',
42                            'say {#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>} people'),
43                      array('say \'#hello\' people',
44                            'say \'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>\' people'),
45
46                      // Unicode legit letters
47                      array('#éclair yummy',
48                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('éclair'))) . '" rel="tag">éclair</a></span> yummy'),
49                      array('#维基百科 zh.wikipedia!',
50                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span> zh.wikipedia!'),
51                      array('#Россия russia',
52                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('Россия'))) . '" rel="tag">Россия</a></span> russia'),
53
54                      // Unicode punctuators -- the ideographic "," separates the tag, just as "," does
55                      array('#维基百科,zh.wikipedia!',
56                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'),
57                      array('#维基百科,zh.wikipedia!',
58                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'),
59
60                      );
61     }
62 }
63