| 
									
										
										
										
											2009-08-25 10:33:16 +12: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 18:42:34 -04:00
										 |  |  |  | define('STATUSNET', true); | 
					
						
							| 
									
										
										
										
											2009-09-27 16:52:15 -04:00
										 |  |  |  | define('LACONICA', true); | 
					
						
							| 
									
										
										
										
											2009-08-25 10:33:16 +12:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | require_once INSTALLDIR . '/lib/common.php'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-26 10:00:29 +12:00
										 |  |  |  | class HashTagDetectionTests extends PHPUnit_Framework_TestCase | 
					
						
							| 
									
										
										
										
											2009-08-25 10:33:16 +12:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |     /** | 
					
						
							|  |  |  |  |      * @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 17:52:16 -04: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'), | 
					
						
							| 
									
										
										
										
											2011-02-25 10:25:13 -08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                      // Unicode legit letters
 | 
					
						
							|  |  |  |  |                      array('#éclair yummy', | 
					
						
							|  |  |  |  |                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('éclair'))) . '" rel="tag">éclair</a></span> yummy'), | 
					
						
							|  |  |  |  |                      array('#维基百科 zh.wikipedia!', | 
					
						
							|  |  |  |  |                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span> zh.wikipedia!'), | 
					
						
							|  |  |  |  |                      array('#Россия russia', | 
					
						
							|  |  |  |  |                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('Россия'))) . '" rel="tag">Россия</a></span> russia'), | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                      // Unicode punctuators -- the ideographic "," separates the tag, just as "," does
 | 
					
						
							|  |  |  |  |                      array('#维基百科,zh.wikipedia!', | 
					
						
							|  |  |  |  |                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'), | 
					
						
							|  |  |  |  |                      array('#维基百科,zh.wikipedia!', | 
					
						
							|  |  |  |  |                            '#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'), | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-25 10:33:16 +12:00
										 |  |  |  |                      ); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 |