@@ -18,4 +18,65 @@ public function test_create_tournament(
1818 ) {
1919
2020 }
21+
22+ public function test_truncate_tournament_description () {
23+ $ reflection = new ReflectionMethod ($ this ->object , 'truncate_tournament_description ' );
24+ $ reflection ->setAccessible (true );
25+
26+ $ description = 'short ' ;
27+ $ shortDescription = $ reflection ->invoke ($ this ->object , $ description );
28+ $ this ->assertEquals ($ description , $ shortDescription , 'Short descriptions should not be truncated ' );
29+
30+ $ description = '12345678901234567890123456789012345678901234567890 ' .
31+ '12345678901234567890123456789012345678901234567890 ' .
32+ '12345678901234567890123456789012345678901234567890 ' .
33+ '12345678901234567890123456789012345678901234567890 ' .
34+ '12345678901234567890123456789012345678901234567890 ' .
35+ '12345678901234567890123456789012345678901234567890 ' ;
36+ $ shortDescription = $ reflection ->invoke ($ this ->object , $ description );
37+ $ this ->assertEquals (
38+ '12345678901234567890123456789012345678901234567890 ' .
39+ '12345678901234567890123456789012345678901234567890 ' .
40+ '12345678901234567890123456789012345678901234567890 ' .
41+ '12345678901234567890123456789012345678901234567890 ' .
42+ '123456789012345678901234567890... ' ,
43+ $ shortDescription ,
44+ 'Long text descriptions should be truncated appropriately '
45+ );
46+
47+ $ description = '[forum=1,6]text[/forum]456789012345678901234567890 ' .
48+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
49+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
50+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
51+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
52+ '12345678901234567890123456789012345678901234567890 ' ;
53+ $ shortDescription = $ reflection ->invoke ($ this ->object , $ description );
54+ $ this ->assertEquals (
55+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
56+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
57+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
58+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
59+ '[forum=1,6]text[/forum]4567890... ' ,
60+ $ shortDescription ,
61+ 'Early markup should not be removed '
62+ );
63+
64+ $ description = '[forum=1,6]text[/forum]456789012345678901234567890 ' .
65+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
66+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
67+ '[forum=1,6]text[/forum]456789012345678901234567890 ' .
68+ '1234567890[forum=1,6]text[/forum]45678901234567890 ' .
69+ '12345678901234567890123456789012345678901234567890 ' ;
70+ $ shortDescription = $ reflection ->invoke ($ this ->object , $ description );
71+ $ this ->assertEquals (
72+ 'text456789012345678901234567890 ' .
73+ 'text456789012345678901234567890 ' .
74+ 'text456789012345678901234567890 ' .
75+ 'text456789012345678901234567890 ' .
76+ '1234567890text4567890123456789012345678901234567890 ' .
77+ '123456789012345678901234567890... ' ,
78+ $ shortDescription ,
79+ 'Late square close brackets should trigger BBCode removal '
80+ );
81+ }
2182}
0 commit comments