]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/HashTagDetectionTests.php
Merge branch '0.9.x' of git@gitorious.org:laconica/mainline into 0.9.x
[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('STATUSNET', true);
10
11 require_once INSTALLDIR . '/lib/common.php';
12
13 class HashTagDetectionTests extends PHPUnit_Framework_TestCase
14 {
15     /**
16      * @dataProvider provider
17      *
18      */
19     public function testProduction($content, $expected)
20     {
21         $rendered = common_render_text($content);
22         $this->assertEquals($expected, $rendered);
23     }
24
25     static public function provider()
26     {
27         return array(
28                      array('hello',
29                            'hello'),
30                      array('#hello people',
31                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span> people'),
32                      array('"#hello" people',
33                            '&quot;#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>&quot; people'),
34                      array('say "#hello" people',
35                            'say &quot;#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>&quot; people'),
36                      array('say (#hello) people',
37                            'say (#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>) people'),
38                      array('say [#hello] people',
39                            'say [#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>] people'),
40                      array('say {#hello} people',
41                            'say {#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>} people'),
42                      array('say \'#hello\' people',
43                            'say \'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>\' people'),
44                      );
45     }
46 }
47