]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/HashTagDetectionTests.php
Merge branch 'i18n-work' into i18n-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 define('LACONICA', true);
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     }
47 }
48