6 require_once 'include/template_processor.php';
\r
7 require_once 'include/text.php';
8 require_once 'mod/item.php';
11 return array(array('id'=>15, 'network'=>'stat', 'alias'=>'Mike', 'nick'=>'Mike', 'url'=>"http://justatest.de"));
14 function dbesc($str) {
18 class GetTagsTest extends PHPUnit_Framework_TestCase {
\r
20 public function setUp() {
\r
22 get_include_path() . PATH_SEPARATOR
\r
23 . 'include' . PATH_SEPARATOR
\r
24 . 'library' . PATH_SEPARATOR
\r
25 . 'library/phpsec' . PATH_SEPARATOR
\r
30 * test with one Person tag
\r
32 public function testGetTagsShortPerson() {
\r
35 $tags=get_tags($text);
\r
39 handle_body($text, $inform, $str_tags, 11, $tags[0]);
41 $this->assertEquals("@Mike", $tags[0]);
42 $this->assertEquals($text, "hi @[url=http://justatest.de]Mike[/url]");
\r
46 * Test with one hash tag.
48 public function testGetTagsShortTag() {
\r
49 $text="This is a #test_case";
\r
51 $tags=get_tags($text);
\r
53 $this->assertEquals("#test_case", $tags[0]);
\r
57 * test with a person and a hash tag
59 public function testGetTagsShortTagAndPerson() {
\r
60 $text="hi @Mike This is a #test_case";
\r
62 $tags=get_tags($text);
\r
66 handle_body($text, $inform, $str_tags, 11, $tags[0]);
68 $this->assertEquals("hi @[url=http://justatest.de]Mike[/url] This is a #test_case", $text);
\r
69 $this->assertEquals("@Mike", $tags[0]);
\r
70 $this->assertEquals("#test_case", $tags[1]);
\r
74 * test with a person, a hash tag and some special chars.
76 public function testGetTagsShortTagAndPersonSpecialChars() {
\r
77 $text="hi @Mike, This is a #test_case.";
\r
79 $tags=get_tags($text);
\r
81 $this->assertEquals("@Mike", $tags[0]);
\r
82 $this->assertEquals("#test_case", $tags[1]);
\r
86 * Test with a person tag and text behind it.
88 public function testGetTagsPersonOnly() {
\r
89 $text="@Test I saw the Theme Dev group was created.";
\r
91 $tags=get_tags($text);
\r
93 $this->assertEquals("@Test", $tags[0]);
\r
97 * test with two persons and one special tag.
99 public function testGetTags2Persons1TagSpecialChars() {
\r
100 $text="hi @Mike, I'm just writing #test_cases, so"
\r
101 ." so @somebody@friendica.com may change #things.";
\r
103 $tags=get_tags($text);
\r
105 $this->assertEquals("@Mike", $tags[0]);
\r
106 $this->assertEquals("#test_cases", $tags[1]);
\r
107 $this->assertEquals("@somebody@friendica.com", $tags[2]);
\r
108 $this->assertEquals("#things", $tags[3]);
\r
112 * test with a long text.
114 public function testGetTags() {
\r
115 $text="hi @Mike, I'm just writing #test_cases, "
\r
116 ." so @somebody@friendica.com may change #things. Of course I "
\r
117 ."look for a lot of #pitfalls, like #tags at the end of a sentence "
\r
118 ."@comment. I hope noone forgets about @fullstops.because that might"
\r
119 ." break #things. @Mike@campino@friendica.eu is also #nice, isn't it? "
\r
120 ."Now, add a @first_last tag. ";
\r
121 //TODO check whether this are all variants (no, auto-stuff is missing).
\r
123 $tags=get_tags($text);
\r
125 $this->assertEquals("@Mike", $tags[0]);
\r
126 $this->assertEquals("#test_cases", $tags[1]);
\r
127 $this->assertEquals("@somebody@friendica.com", $tags[2]);
\r
128 $this->assertEquals("#things", $tags[3]);
\r
129 $this->assertEquals("#pitfalls", $tags[4]);
\r
130 $this->assertEquals("#tags", $tags[5]);
\r
131 $this->assertEquals("@comment", $tags[6]);
\r
132 $this->assertEquals("@fullstops", $tags[7]);
\r
133 $this->assertEquals("#things", $tags[8]);
\r
134 $this->assertEquals("@Mike", $tags[9]);
\r
135 $this->assertEquals("@campino@friendica.eu", $tags[10]);
\r
136 $this->assertEquals("#nice", $tags[11]);
\r
137 $this->assertEquals("@first_last", $tags[12]);
\r
141 * test with an empty string
143 public function testGetTagsEmpty() {
\r
144 $tags=get_tags("");
\r
145 $this->assertEquals(0, count($tags));
\r