- Timestamp:
- 01/29/09 13:35:57 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ActionTrackerPlugin/test/unit/ActionTrackerPlugin/ActionTests.pm
r1340 r2226 5 5 use strict; 6 6 7 use TWiki::Plugins::ActionTrackerPlugin::Action;8 use TWiki::Plugins::ActionTrackerPlugin::Format;7 use Foswiki::Plugins::ActionTrackerPlugin::Action; 8 use Foswiki::Plugins::ActionTrackerPlugin::Format; 9 9 use Time::ParseDate; 10 10 use CGI; … … 17 17 # Have to do this to force a read of the configuration 18 18 BEGIN { 19 new TWiki();20 $ TWiki::cfg{Plugins}{ActionTrackerPlugin}{Enabled} = 1;19 new Foswiki(); 20 $Foswiki::cfg{Plugins}{ActionTrackerPlugin}{Enabled} = 1; 21 21 }; 22 22 … … 24 24 my $this = shift; 25 25 $this->SUPER::set_up(); 26 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 26 27 $Foswiki::cfg{DisplayTimeValues} = 'servertime'; 28 $Foswiki::cfg{DefaultDateFormat} = '$day $month $year'; 29 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 27 30 } 28 31 … … 30 33 my $this = shift; 31 34 $this->SUPER::tear_down(); 32 TWiki::Plugins::ActionTrackerPlugin::Action::unextendTypes();35 Foswiki::Plugins::ActionTrackerPlugin::Action::unextendTypes(); 33 36 } 34 37 … … 37 40 38 41 # no state -> first state 39 my $action = new TWiki::Plugins::ActionTrackerPlugin::Action(42 my $action = new Foswiki::Plugins::ActionTrackerPlugin::Action( 40 43 "Test","Topic",0,"", ""); 41 44 $this->assert_str_equals("open", $action->{state}, $action->stringify()); 42 45 # closed defined -> closed state 43 $action = new TWiki::Plugins::ActionTrackerPlugin::Action(46 $action = new Foswiki::Plugins::ActionTrackerPlugin::Action( 44 47 "Test","Topic",0,"closed", ""); 45 48 $this->assert_str_equals("closed", $action->{state}); 46 49 $action = 47 new TWiki::Plugins::ActionTrackerPlugin::Action(50 new Foswiki::Plugins::ActionTrackerPlugin::Action( 48 51 "Test","Topic",0,"closed=10-may-05", ""); 49 52 $this->assert_str_equals("closed", $action->{state}); 50 53 $action = 51 TWiki::Plugins::ActionTrackerPlugin::Action->new(54 Foswiki::Plugins::ActionTrackerPlugin::Action->new( 52 55 "Test","Topic",0,"closer=Flicka", ""); 53 56 $this->assert_str_equals("open", $action->{state}); 54 57 # state def overrides closed defined 55 58 $action = 56 new TWiki::Plugins::ActionTrackerPlugin::Action(59 new Foswiki::Plugins::ActionTrackerPlugin::Action( 57 60 "Test","Topic",0,"",'closed,state="open"'); 58 61 $this->assert_str_equals("open", $action->{state}); … … 63 66 64 67 my $action = 65 new TWiki::Plugins::ActionTrackerPlugin::Action(68 new Foswiki::Plugins::ActionTrackerPlugin::Action( 66 69 "Test","Topic2",0, 67 70 "web=Wrong,topic=Wrong web=Right", ""); … … 74 77 75 78 my $action = 76 new TWiki::Plugins::ActionTrackerPlugin::Action(79 new Foswiki::Plugins::ActionTrackerPlugin::Action( 77 80 "Test","Topic",0, 78 81 'who="Who" due="2 Jun 02" open', ""); 79 82 $this->assert(!$action->isLate()); 80 83 $this->assert_num_equals(2, $action->daysToGo()); 81 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime(84 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime( 82 85 "1 Jun 2002 23:59:59"); 83 86 $this->assert(!$action->isLate()); 84 87 $this->assert_num_equals(0, $action->daysToGo()); 85 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime(88 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime( 86 89 "2 Jun 2002 00:00:01"); 87 90 $this->assert($action->isLate()); 88 91 $this->assert_num_equals(-1, $action->daysToGo()); 89 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime(92 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime( 90 93 "3 Jun 2002 00:00:01"); 91 94 $this->assert($action->isLate()); 92 95 $this->assert_num_equals(-1, $action->daysToGo()); 93 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime(96 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime( 94 97 "4 Jun 2002 00:00:01"); 95 98 $this->assert($action->isLate()); 96 99 $this->assert_num_equals(-2, $action->daysToGo()); 97 100 $action = new 98 TWiki::Plugins::ActionTrackerPlugin::Action(101 Foswiki::Plugins::ActionTrackerPlugin::Action( 99 102 "Test","Topic",0, 100 103 'who="Who" due="2 Jun 02" closed', ""); … … 106 109 107 110 my $action = 108 new TWiki::Plugins::ActionTrackerPlugin::Action(111 new Foswiki::Plugins::ActionTrackerPlugin::Action( 109 112 "Test", "Topic", 0, 110 113 'who="JohnDoe, SlyStallone",due="2 Jun 02",notify="SamPeckinpah, QuentinTarantino",creator="ThomasMoore"', … … 119 122 120 123 my $action = 121 new TWiki::Plugins::ActionTrackerPlugin::Action(124 new Foswiki::Plugins::ActionTrackerPlugin::Action( 122 125 "Test", "Topic", 0, 123 'who="JohnDoe,SlyStallone,'.$ TWiki::cfg{DefaultUserWikiName}.'" due="2 Jun 02" state=open notify="SamPeckinpah,QuentinTarantino" created="1999-01-01" creator="ThomasMoore"',126 'who="JohnDoe,SlyStallone,'.$Foswiki::cfg{DefaultUserWikiName}.'" due="2 Jun 02" state=open notify="SamPeckinpah,QuentinTarantino" created="1999-01-01" creator="ThomasMoore"', 124 127 "A new action"); 125 128 126 my $attrs = new TWiki::Attrs("who=JohnDoe",1);129 my $attrs = new Foswiki::Attrs("who=JohnDoe",1); 127 130 $this->assert($action->matches($attrs),$attrs->stringify()); 128 $attrs = new TWiki::Attrs("who=$this->{users_web}.JohnDoe",1);129 $this->assert($action->matches($attrs)); 130 $attrs = new TWiki::Attrs("who=me",1);131 $this->assert($action->matches($attrs)); 132 $attrs = new TWiki::Attrs("who=JohnSmith",1);133 $this->assert(!$action->matches($attrs)); 134 $attrs = new TWiki::Attrs("who=$this->{users_web}.SlyStallone",1);135 $this->assert($action->matches($attrs)); 136 $attrs = new TWiki::Attrs("who",1);137 $this->assert(!$action->matches($attrs)); 138 139 $attrs = new TWiki::Attrs('notify="SamPeckinpah"',1);140 $this->assert($action->matches($attrs)); 141 $attrs = new TWiki::Attrs('notify="QuentinTarantino"',1);142 $this->assert($action->matches($attrs)); 143 $attrs = new TWiki::Attrs('notify="JonasSalk,QuentinTarantino"',1);144 $this->assert($action->matches($attrs)); 145 $attrs = new TWiki::Attrs('notify="SamBrowne,OscarWilde"',1);146 $this->assert(!$action->matches($attrs)); 147 $attrs = new TWiki::Attrs("notify",1);148 $this->assert(!$action->matches($attrs)); 149 150 $attrs = new TWiki::Attrs('state="open"',1);151 $this->assert($action->matches($attrs)); 152 $attrs = new TWiki::Attrs("open",1);153 $this->assert($action->matches($attrs)); 154 $attrs = new TWiki::Attrs("openday",1);155 $this->assert(!$action->matches($attrs)); 156 $attrs = new TWiki::Attrs('state="(?!closed).*"',0);157 $this->assert($action->matches($attrs)); 158 159 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("4 Jun 2002");160 $attrs = new TWiki::Attrs("within='+2'",1);161 $this->assert(!$action->matches($attrs)); 162 $attrs = new TWiki::Attrs("within='2'",1);163 $this->assert($action->matches($attrs)); 164 $attrs = new TWiki::Attrs("within='+1'",1);165 $this->assert(!$action->matches($attrs)); 166 $attrs = new TWiki::Attrs("within='1'",1);167 $this->assert(!$action->matches($attrs)); 168 $attrs = new TWiki::Attrs("within='-1'",1);169 $this->assert(!$action->matches($attrs)); 170 $attrs = new TWiki::Attrs("within='-2'",1);171 $this->assert($action->matches($attrs)); 172 173 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002");174 $attrs = new TWiki::Attrs("within='+2'",1);175 $this->assert($action->matches($attrs)); 176 $attrs = new TWiki::Attrs("within='2'",1);177 $this->assert($action->matches($attrs)); 178 $attrs = new TWiki::Attrs("within='+1'",1);179 $this->assert(!$action->matches($attrs)); 180 $attrs = new TWiki::Attrs("within='1'",1);181 $this->assert(!$action->matches($attrs)); 182 $attrs = new TWiki::Attrs("within='-2'",1);183 $this->assert(!$action->matches($attrs)); 184 185 $attrs = new TWiki::Attrs("late",1);186 $this->assert(!$action->matches($attrs)); 187 188 $attrs = new TWiki::Attrs("web=Test",1);189 $this->assert($action->matches($attrs)); 190 $attrs = new TWiki::Attrs('web=".*t"',1);191 $this->assert($action->matches($attrs)); 192 $attrs = new TWiki::Attrs('web="A.*"',1);193 $this->assert(!$action->matches($attrs)); 194 195 $attrs = new TWiki::Attrs("topic=Topic",1);196 $this->assert($action->matches($attrs)); 197 $attrs = new TWiki::Attrs('topic=".*c"',1);198 $this->assert($action->matches($attrs)); 199 $attrs = new TWiki::Attrs('topic="A.*"',1);200 $this->assert(!$action->matches($attrs)); 201 202 $attrs = new TWiki::Attrs('due="2 Jun 02"',1);203 $this->assert($action->matches($attrs)); 204 $attrs = new TWiki::Attrs('due="3 Jun 02"',1);205 $this->assert(!$action->matches($attrs)); 206 $attrs = new TWiki::Attrs('due="< 3 Jun 02"',1);207 $this->assert($action->matches($attrs)); 208 $attrs = new TWiki::Attrs('due="> 3 Jun 02"',1);209 $this->assert(!$action->matches($attrs)); 210 $attrs = new TWiki::Attrs('due="> 1 Jun 02"',1);211 $this->assert($action->matches($attrs)); 212 $attrs = new TWiki::Attrs('due="< 1 Jun 02"',1);213 $this->assert(!$action->matches($attrs)); 214 215 $attrs = new TWiki::Attrs("creator=ThomasMoore",1);216 $this->assert($action->matches($attrs)); 217 $attrs = new TWiki::Attrs("creator=QuentinTarantino",1);218 $this->assert(!$action->matches($attrs)); 219 220 $attrs = new TWiki::Attrs('created="1999-01-01"',1);221 $this->assert($action->matches($attrs)); 222 $attrs = new TWiki::Attrs('created="2 Jun 02"',1);223 $this->assert(!$action->matches($attrs)); 224 $attrs = new TWiki::Attrs('created="2 Jan 1999"',1);225 $this->assert(!$action->matches($attrs)); 226 $attrs = new TWiki::Attrs('created="< 2 Jan 1999"',1);227 $this->assert($action->matches($attrs)); 228 $attrs = new TWiki::Attrs('created="> 2 Jan 1999"',1);229 $this->assert(!$action->matches($attrs)); 230 $attrs = new TWiki::Attrs('created=">= 1 Jan 1999"',1);231 $this->assert($action->matches($attrs)); 232 $attrs = new TWiki::Attrs('created="< 1 Jan 1999"',1);233 $this->assert(!$action->matches($attrs)); 234 235 $attrs = new TWiki::Attrs("closed",1);236 $this->assert(!$action->matches($attrs)); 237 $attrs = new TWiki::Attrs('closed="2 Jun 02"',1);238 $this->assert(!$action->matches($attrs)); 239 $attrs = new TWiki::Attrs('closed="1 Jan 1999"',1);131 $attrs = new Foswiki::Attrs("who=$this->{users_web}.JohnDoe",1); 132 $this->assert($action->matches($attrs)); 133 $attrs = new Foswiki::Attrs("who=me",1); 134 $this->assert($action->matches($attrs)); 135 $attrs = new Foswiki::Attrs("who=JohnSmith",1); 136 $this->assert(!$action->matches($attrs)); 137 $attrs = new Foswiki::Attrs("who=$this->{users_web}.SlyStallone",1); 138 $this->assert($action->matches($attrs)); 139 $attrs = new Foswiki::Attrs("who",1); 140 $this->assert(!$action->matches($attrs)); 141 142 $attrs = new Foswiki::Attrs('notify="SamPeckinpah"',1); 143 $this->assert($action->matches($attrs)); 144 $attrs = new Foswiki::Attrs('notify="QuentinTarantino"',1); 145 $this->assert($action->matches($attrs)); 146 $attrs = new Foswiki::Attrs('notify="JonasSalk,QuentinTarantino"',1); 147 $this->assert($action->matches($attrs)); 148 $attrs = new Foswiki::Attrs('notify="SamBrowne,OscarWilde"',1); 149 $this->assert(!$action->matches($attrs)); 150 $attrs = new Foswiki::Attrs("notify",1); 151 $this->assert(!$action->matches($attrs)); 152 153 $attrs = new Foswiki::Attrs('state="open"',1); 154 $this->assert($action->matches($attrs)); 155 $attrs = new Foswiki::Attrs("open",1); 156 $this->assert($action->matches($attrs)); 157 $attrs = new Foswiki::Attrs("openday",1); 158 $this->assert(!$action->matches($attrs)); 159 $attrs = new Foswiki::Attrs('state="(?!closed).*"',0); 160 $this->assert($action->matches($attrs)); 161 162 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("4 Jun 2002"); 163 $attrs = new Foswiki::Attrs("within='+2'",1); 164 $this->assert(!$action->matches($attrs)); 165 $attrs = new Foswiki::Attrs("within='2'",1); 166 $this->assert($action->matches($attrs)); 167 $attrs = new Foswiki::Attrs("within='+1'",1); 168 $this->assert(!$action->matches($attrs)); 169 $attrs = new Foswiki::Attrs("within='1'",1); 170 $this->assert(!$action->matches($attrs)); 171 $attrs = new Foswiki::Attrs("within='-1'",1); 172 $this->assert(!$action->matches($attrs)); 173 $attrs = new Foswiki::Attrs("within='-2'",1); 174 $this->assert($action->matches($attrs)); 175 176 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 177 $attrs = new Foswiki::Attrs("within='+2'",1); 178 $this->assert($action->matches($attrs)); 179 $attrs = new Foswiki::Attrs("within='2'",1); 180 $this->assert($action->matches($attrs)); 181 $attrs = new Foswiki::Attrs("within='+1'",1); 182 $this->assert(!$action->matches($attrs)); 183 $attrs = new Foswiki::Attrs("within='1'",1); 184 $this->assert(!$action->matches($attrs)); 185 $attrs = new Foswiki::Attrs("within='-2'",1); 186 $this->assert(!$action->matches($attrs)); 187 188 $attrs = new Foswiki::Attrs("late",1); 189 $this->assert(!$action->matches($attrs)); 190 191 $attrs = new Foswiki::Attrs("web=Test",1); 192 $this->assert($action->matches($attrs)); 193 $attrs = new Foswiki::Attrs('web=".*t"',1); 194 $this->assert($action->matches($attrs)); 195 $attrs = new Foswiki::Attrs('web="A.*"',1); 196 $this->assert(!$action->matches($attrs)); 197 198 $attrs = new Foswiki::Attrs("topic=Topic",1); 199 $this->assert($action->matches($attrs)); 200 $attrs = new Foswiki::Attrs('topic=".*c"',1); 201 $this->assert($action->matches($attrs)); 202 $attrs = new Foswiki::Attrs('topic="A.*"',1); 203 $this->assert(!$action->matches($attrs)); 204 205 $attrs = new Foswiki::Attrs('due="2 Jun 02"',1); 206 $this->assert($action->matches($attrs)); 207 $attrs = new Foswiki::Attrs('due="3 Jun 02"',1); 208 $this->assert(!$action->matches($attrs)); 209 $attrs = new Foswiki::Attrs('due="< 3 Jun 02"',1); 210 $this->assert($action->matches($attrs)); 211 $attrs = new Foswiki::Attrs('due="> 3 Jun 02"',1); 212 $this->assert(!$action->matches($attrs)); 213 $attrs = new Foswiki::Attrs('due="> 1 Jun 02"',1); 214 $this->assert($action->matches($attrs)); 215 $attrs = new Foswiki::Attrs('due="< 1 Jun 02"',1); 216 $this->assert(!$action->matches($attrs)); 217 218 $attrs = new Foswiki::Attrs("creator=ThomasMoore",1); 219 $this->assert($action->matches($attrs)); 220 $attrs = new Foswiki::Attrs("creator=QuentinTarantino",1); 221 $this->assert(!$action->matches($attrs)); 222 223 $attrs = new Foswiki::Attrs('created="1999-01-01"',1); 224 $this->assert($action->matches($attrs)); 225 $attrs = new Foswiki::Attrs('created="2 Jun 02"',1); 226 $this->assert(!$action->matches($attrs)); 227 $attrs = new Foswiki::Attrs('created="2 Jan 1999"',1); 228 $this->assert(!$action->matches($attrs)); 229 $attrs = new Foswiki::Attrs('created="< 2 Jan 1999"',1); 230 $this->assert($action->matches($attrs)); 231 $attrs = new Foswiki::Attrs('created="> 2 Jan 1999"',1); 232 $this->assert(!$action->matches($attrs)); 233 $attrs = new Foswiki::Attrs('created=">= 1 Jan 1999"',1); 234 $this->assert($action->matches($attrs)); 235 $attrs = new Foswiki::Attrs('created="< 1 Jan 1999"',1); 236 $this->assert(!$action->matches($attrs)); 237 238 $attrs = new Foswiki::Attrs("closed",1); 239 $this->assert(!$action->matches($attrs)); 240 $attrs = new Foswiki::Attrs('closed="2 Jun 02"',1); 241 $this->assert(!$action->matches($attrs)); 242 $attrs = new Foswiki::Attrs('closed="1 Jan 1999"',1); 240 243 $this->assert(!$action->matches($attrs)); 241 244 242 245 # make it late 243 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002");244 $attrs = new TWiki::Attrs("late",1);245 $this->assert($action->matches($attrs)); 246 247 $attrs = new TWiki::Attrs("within=-1",1);246 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002"); 247 $attrs = new Foswiki::Attrs("late",1); 248 $this->assert($action->matches($attrs)); 249 250 $attrs = new Foswiki::Attrs("within=-1",1); 248 251 $this->assert($action->matches($attrs), $action->secsToGo()); 249 $attrs = new TWiki::Attrs("within=+1",1);252 $attrs = new Foswiki::Attrs("within=+1",1); 250 253 $this->assert(!$action->matches($attrs), $action->secsToGo()); 251 254 } … … 254 257 my $this = shift; 255 258 256 my $action = new TWiki::Plugins::ActionTrackerPlugin::Action(259 my $action = new Foswiki::Plugins::ActionTrackerPlugin::Action( 257 260 "Test", "Topic", 0, 258 261 'who="JohnDoe,SlyStallone",due="2 Jun 02" closed="2 Dec 00" closer="Death" notify="SamPeckinpah,QuentinTarantino" created="1 Jan 1999" creator="ThomasMoore"', 259 262 "A new action"); 260 my $attrs = new TWiki::Attrs("closed",1,1);263 my $attrs = new Foswiki::Attrs("closed",1,1); 261 264 $this->assert($action->matches($attrs), $action->stringify()); 262 $attrs = new TWiki::Attrs('closed="2 Dec 00"',1);263 $this->assert($action->matches($attrs)); 264 $attrs = new TWiki::Attrs('closed="> 1 Dec 00"',1);265 $this->assert($action->matches($attrs)); 266 $attrs = new TWiki::Attrs('closed="< 1 Dec 00"',1);267 $this->assert(!$action->matches($attrs)); 268 $attrs = new TWiki::Attrs('closed="2 Dec 01"',1);269 $this->assert(!$action->matches($attrs)); 270 271 $attrs = new TWiki::Attrs("closer=Death",1,1);272 $this->assert($action->matches($attrs)); 273 $attrs = new TWiki::Attrs("open",1);265 $attrs = new Foswiki::Attrs('closed="2 Dec 00"',1); 266 $this->assert($action->matches($attrs)); 267 $attrs = new Foswiki::Attrs('closed="> 1 Dec 00"',1); 268 $this->assert($action->matches($attrs)); 269 $attrs = new Foswiki::Attrs('closed="< 1 Dec 00"',1); 270 $this->assert(!$action->matches($attrs)); 271 $attrs = new Foswiki::Attrs('closed="2 Dec 01"',1); 272 $this->assert(!$action->matches($attrs)); 273 274 $attrs = new Foswiki::Attrs("closer=Death",1,1); 275 $this->assert($action->matches($attrs)); 276 $attrs = new Foswiki::Attrs("open",1); 274 277 $this->assert(!$action->matches($attrs)); 275 278 } … … 278 281 my $this = shift; 279 282 280 my $action = new TWiki::Plugins::ActionTrackerPlugin::Action(283 my $action = new Foswiki::Plugins::ActionTrackerPlugin::Action( 281 284 "Test", "Topic", 0, 282 285 'who="JohnDoe" due="2 Jun 02" state=open notify="SamPeckinpah,QuentinTarantino" created="1 Jan 1999" creator="ThomasMoore"', 283 286 "A new action"); 284 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(287 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 285 288 "|Who|Due|","|\$who|","","Who: \$who \$who","\$who,\$due"); 286 289 my $s = $fmt->formatStringTable([$action]); 287 290 $this->assert_str_equals("Who: $this->{users_web}.JohnDoe $this->{users_web}.JohnDoe\n",$s, 288 291 $fmt->stringify()); 289 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(292 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 290 293 "","","","Due: \$due"); 291 294 # make it late 292 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002");293 $s = $fmt->formatStringTable([$action]); 294 $this->assert_str_equals("Due: Sun,02 Jun 2002 (LATE)\n", $s);295 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002"); 296 $s = $fmt->formatStringTable([$action]); 297 $this->assert_str_equals("Due: 02 Jun 2002 (LATE)\n", $s); 295 298 # make it ontime 296 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("1 Jun 2002");297 $s = $fmt->formatStringTable([$action]); 298 $this->assert_str_equals("Due: Sun,02 Jun 2002\n", $s);299 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("1 Jun 2002"); 300 $s = $fmt->formatStringTable([$action]); 301 $this->assert_str_equals("Due: 02 Jun 2002\n", $s); 299 302 # make it late again 300 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002");301 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(303 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002"); 304 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 302 305 "","","", "State: \$state\n"); 303 306 $s = $fmt->formatStringTable([$action]); 304 307 $this->assert_str_equals("State: open\n\n", $s); 305 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(308 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 306 309 "","", "","Notify: \$notify\n"); 307 310 $s = $fmt->formatStringTable([$action]); 308 311 $this->assert_str_equals( 309 312 "Notify: $this->{users_web}.SamPeckinpah, $this->{users_web}.QuentinTarantino\n\n", $s); 310 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(313 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 311 314 "","", "", "\$creator"); 312 315 $s = $fmt->formatStringTable([$action]); 313 316 $this->assert_str_equals($s, "$this->{users_web}.ThomasMoore\n"); 314 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(317 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 315 318 "","", "","|\$created|"); 316 319 $s = $fmt->formatStringTable([$action]); 317 $this->assert_str_equals("| Fri,01 Jan 1999|\n", $s);318 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(320 $this->assert_str_equals("|01 Jan 1999|\n", $s); 321 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 319 322 "","", "","|\$edit|"); 320 323 $s = $fmt->formatStringTable([$action]); 321 324 $this->assert_str_equals("||\n", $s); 322 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(325 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 323 326 "","", "","\$web.\$topic"); 324 327 $s = $fmt->formatStringTable([$action]); 325 328 $this->assert_str_equals("Test.Topic\n", $s); 326 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(329 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 327 330 "","", "", 'Text "$text"'); 328 331 $s = $fmt->formatStringTable([$action]); 329 332 $this->assert_str_equals("Text \"A new action\"\n", $s); 330 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(333 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 331 334 "","", "","|\$n\$n()\$nop()\$quot\$percnt\$dollar|"); 332 335 $s = $fmt->formatStringTable([$action]); 333 336 $this->assert_str_equals("|\n\n\"%\$|\n", $s); 334 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(337 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 335 338 "","","","Who: \$who Creator: \$creator"); 336 339 $s = $fmt->formatStringTable([$action]); … … 342 345 my $this = shift; 343 346 344 my $action = new TWiki::Plugins::ActionTrackerPlugin::Action(347 my $action = new Foswiki::Plugins::ActionTrackerPlugin::Action( 345 348 "Test","Topic", 0, 346 349 'who=JohnDoe due="2 Jun 02" closed="1-Jan-03" closer="LucBesson"', 347 350 "A new action"); 348 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(351 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 349 352 "","", "", "|\$closed|\$closer|"); 350 353 my $s = $fmt->formatStringTable([$action]); 351 354 $this->assert_str_equals( 352 $s, "| Wed,01 Jan 2003|$this->{users_web}.LucBesson|\n");355 $s, "|01 Jan 2003|$this->{users_web}.LucBesson|\n"); 353 356 } 354 357 … … 356 359 my $this = shift; 357 360 358 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002");359 my $action = TWiki::Plugins::ActionTrackerPlugin::Action->new(361 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 362 my $action = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 360 363 "Test", "Topic", 0, 361 364 'who=JohnDoe due="2 Jun 02" state=open notify="SamPeckinpah,QuentinTarantino" created="1 Jan 1999" creator="ThomasMoore"', 362 365 "A new action"); 363 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(366 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 364 367 "|Who|Due|", "|\$who|\$due|", "rows"); 365 368 my $s = $fmt->formatHTMLTable([$action], "name", 0, 'atp'); 366 $s =~ s/<table class=\"atp \">//;369 $s =~ s/<table class=\"atpSearch\">//; 367 370 $s =~ s/<\/table>//; 368 371 $s =~ s/\n//g; 369 $this->assert_str_equals("<tr><th >Who</th><td><a name=\"AcTion0\" />$this->{users_web}.JohnDoe</td></tr><tr><th>Due</th><td><span class=\"atpOpen\">Sun,02 Jun 2002</span></td></tr>", $s);372 $this->assert_str_equals("<tr><th align=\"right\">Who</th><td><a name=\"AcTion0\" />$this->{users_web}.JohnDoe</td></tr><tr><th align=\"right\">Due</th><td><span class=\"atpOpen\">02 Jun 2002</span></td></tr>", $s); 370 373 } 371 374 … … 373 376 my $this = shift; 374 377 375 my $action = TWiki::Plugins::ActionTrackerPlugin::Action->new(378 my $action = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 376 379 "Test", "Topic", 0, 377 380 'who=JohnDoe due="2 Jun 02" state=open notify="SamPeckinpah,QuentinTarantino, DavidLynch" created="1 Jan 1999" creator="ThomasMoore"', 378 381 "A new action"); 379 382 380 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format("", "|\$who|");383 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format("", "|\$who|"); 381 384 my $s = $fmt->formatHTMLTable([$action], "name", 0, 'atp'); 382 385 $this->assert_html_matches( 383 386 "<td><a name=\"AcTion0\" />$this->{users_web}.JohnDoe</td>", $s); 384 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format("", "| \$due |");387 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format("", "| \$due |"); 385 388 # make it late 386 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002");387 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 388 $this->assert_html_matches( 389 "<td> <span class=\"atpWarn\"> Sun,02 Jun 2002</span> </td>", $s);389 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002"); 390 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 391 $this->assert_html_matches( 392 "<td> <span class=\"atpWarn\">02 Jun 2002</span> </td>", $s); 390 393 391 394 # make it ontime 392 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("1 Jun 2002");393 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(395 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("1 Jun 2002"); 396 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 394 397 "", "| \$due |", ""); 395 398 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 396 399 $this->assert_html_matches( 397 "<td> <span class=\"atpOpen\"> Sun,02 Jun 2002</span> </td>", $s);400 "<td> <span class=\"atpOpen\">02 Jun 2002</span> </td>", $s); 398 401 399 402 # Make it late again 400 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002");401 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(403 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("3 Jun 2002"); 404 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 402 405 "", "| \$state |", ""); 403 406 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 404 407 $this->assert_html_matches("<td> open </td>", $s ); 405 408 406 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format("", "| \$notify |");409 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format("", "| \$notify |"); 407 410 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 408 411 $this->assert_html_matches( … … 410 413 $s ); 411 414 412 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format("", "| \$uid |");415 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format("", "| \$uid |"); 413 416 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 414 417 $this->assert_html_matches("<td> </td>", $s ); 415 418 416 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(419 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 417 420 "", "| \$creator |", ""); 418 421 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 419 422 $this->assert_html_matches("<td> $this->{users_web}.ThomasMoore </td>", $s ); 420 423 421 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(424 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 422 425 "", "| \$created |", ""); 423 426 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 424 $this->assert_html_matches("<td> Fri,01 Jan 1999 </td>", $s );425 426 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(427 $this->assert_html_matches("<td> 01 Jan 1999 </td>", $s ); 428 429 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 427 430 "", "| \$edit |", ""); 428 my $url = "$ TWiki::cfg{DefaultUrlHost}$TWiki::cfg{ScriptUrlPath}/edit$TWiki::cfg{ScriptSuffix}/Test/Topic\\?skin=action%2cpattern;atp_action=AcTion0;t=";431 my $url = "$Foswiki::cfg{DefaultUrlHost}$Foswiki::cfg{ScriptUrlPath}/edit$Foswiki::cfg{ScriptSuffix}/Test/Topic\\?skin=action%2cpattern;atp_action=AcTion0;t="; 429 432 $s = $fmt->formatHTMLTable([$action], "href", 0 ); 430 433 $this->assert($s =~ m(<td> <a href="(.*?)">edit</a> </td>), $s); … … 432 435 $this->assert_matches(qr(^$url\d+$), $1); 433 436 434 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(437 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 435 438 "", "| \$edit |", ""); 436 439 $s = $fmt->formatHTMLTable([$action], "href", 1, 'atp'); … … 441 444 $this->assert_matches(qr/onclick="return atp_editWindow\('$url\d+'\)"/, $x); 442 445 443 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(446 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 444 447 "", "| \$web.\$topic |", ""); 445 448 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); … … 447 450 $this->assert_html_matches('<td> Test.Topic </td>', $s ); 448 451 449 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(452 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 450 453 "", "| \$text |", ""); 451 454 $s = $fmt->formatHTMLTable([$action], "href", 0, 'XXX'); 452 $this->assert( $s =~ /<td> A new action <a href="$ TWiki::cfg{DefaultUrlHost}$TWiki::cfg{ScriptUrlPath}\/view$TWiki::cfg{ScriptSuffix}\/Test\/Topic#AcTion0">/,455 $this->assert( $s =~ /<td> A new action <a href="$Foswiki::cfg{DefaultUrlHost}$Foswiki::cfg{ScriptUrlPath}\/view$Foswiki::cfg{ScriptSuffix}\/Test\/Topic#AcTion0">/, 453 456 $s ); 454 457 455 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(458 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 456 459 "", "| \$n\$n()\$nop()\$quot\$percnt\$dollar |", ""); 457 460 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 458 461 $this->assert_html_matches("<td> <br /><br />\"%\$ </td>", $s ); 459 462 460 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("1 Jun 2002");461 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(463 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("1 Jun 2002"); 464 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 462 465 "", "| \$due |", ""); 463 466 $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 464 467 $this->assert_html_matches( 465 "<td> <span class=\"atpOpen\"> Sun,02 Jun 2002</span> </td>", $s );466 467 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(468 "<td> <span class=\"atpOpen\">02 Jun 2002</span> </td>", $s ); 469 470 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 468 471 "", "|\$who|\$creator|", ""); 469 472 $s = $fmt->formatHTMLTable([$action], "name", 0, 'atp'); … … 476 479 my $this = shift; 477 480 478 my $action = TWiki::Plugins::ActionTrackerPlugin::Action->new(481 my $action = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 479 482 "Test", "Topic", 0, 480 483 'who=JohnDoe due="2 Jun 02" closed="1-Jan-03" closer="LucBesson"', 481 484 "A new action"); 482 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(485 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 483 486 "", "|\$closed|\$closer|", ""); 484 487 my $s = $fmt->formatHTMLTable([$action], "href", 0, 'atp'); 485 488 $this->assert_html_matches( 486 "<td> Wed,01 Jan 2003</td><td>$this->{users_web}.LucBesson</td>", $s );489 "<td>01 Jan 2003</td><td>$this->{users_web}.LucBesson</td>", $s ); 487 490 } 488 491 … … 490 493 my $this = shift; 491 494 492 my $action = new TWiki::Plugins::ActionTrackerPlugin::Action(495 my $action = new Foswiki::Plugins::ActionTrackerPlugin::Action( 493 496 "Test", "Topic", 7, 494 497 "state=closed", "A new action"); 495 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002");498 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 496 499 my $tim = Time::ParseDate::parsedate("31 May 2002"); 497 500 $action->populateMissingFields(); 498 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(501 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 499 502 "","","","|\$uid|\$who|"); 500 503 my $s = $fmt->formatStringTable([$action]); 501 $this->assert_matches(qr/^\|\d\d\d\d\d\d\|$this->{users_web}\.$ TWiki::cfg{DefaultUserWikiName}\|\n/, $s);502 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(504 $this->assert_matches(qr/^\|\d\d\d\d\d\d\|$this->{users_web}\.$Foswiki::cfg{DefaultUserWikiName}\|\n/, $s); 505 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 503 506 "","","","|\$creator|\$created|"); 504 507 $s = $fmt->formatStringTable([$action]); 505 $this->assert_str_equals("|$this->{users_web}.$ TWiki::cfg{DefaultUserWikiName}|Fri,31 May 2002|\n", $s);506 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(508 $this->assert_str_equals("|$this->{users_web}.$Foswiki::cfg{DefaultUserWikiName}|31 May 2002|\n", $s); 509 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 507 510 "","","","|\$closer|\$closed|"); 508 511 $s = $fmt->formatStringTable([$action]); 509 $this->assert_str_equals("|$this->{users_web}.$ TWiki::cfg{DefaultUserWikiName}|Fri,31 May 2002|\n", $s);512 $this->assert_str_equals("|$this->{users_web}.$Foswiki::cfg{DefaultUserWikiName}|31 May 2002|\n", $s); 510 513 $action = 511 new TWiki::Plugins::ActionTrackerPlugin::Action(514 new Foswiki::Plugins::ActionTrackerPlugin::Action( 512 515 "Test", "Topic", 8, 513 516 "who=me", "action"); 514 517 $action->populateMissingFields(); 515 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(518 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 516 519 "","","","|\$who|\$created|"); 517 520 $s = $fmt->formatStringTable([$action]); 518 $this->assert_str_equals("|$this->{users_web}.$ TWiki::cfg{DefaultUserWikiName}|Fri,31 May 2002|\n", $s);521 $this->assert_str_equals("|$this->{users_web}.$Foswiki::cfg{DefaultUserWikiName}|31 May 2002|\n", $s); 519 522 } 520 523 … … 522 525 my $this = shift; 523 526 524 my $action = TWiki::Plugins::ActionTrackerPlugin::Action->new(527 my $action = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 525 528 "Test", "Topic", 5, "due=\"2 Jun 02\" state=closed", "A new action"); 526 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("30 Sep 2001");529 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("30 Sep 2001"); 527 530 $action->populateMissingFields(); 528 531 my $s = $action->stringify(); 529 532 $s =~ s/ uid="\d+"//o; 530 533 $s =~ s/ created="2001-09-30"//o; 531 $s =~ s/ creator="$this->{users_web}\.$ TWiki::cfg{DefaultUserWikiName}"//o;532 $s =~ s/ who="$this->{users_web}\.$ TWiki::cfg{DefaultUserWikiName}"//o;534 $s =~ s/ creator="$this->{users_web}\.$Foswiki::cfg{DefaultUserWikiName}"//o; 535 $s =~ s/ who="$this->{users_web}\.$Foswiki::cfg{DefaultUserWikiName}"//o; 533 536 $s =~ s/ due="2002-06-02"//o; 534 537 $s =~ s/ closed="2001-09-30"//o; 535 $s =~ s/ closer="$this->{users_web}\.$ TWiki::cfg{DefaultUserWikiName}"//o;538 $s =~ s/ closer="$this->{users_web}\.$Foswiki::cfg{DefaultUserWikiName}"//o; 536 539 $s =~ s/ state="closed"//o; 537 540 $this->assert_str_equals("%ACTION{ }% A new action %ENDACTION%", $s); 538 541 539 $action = TWiki::Plugins::ActionTrackerPlugin::Action->new(542 $action = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 540 543 "Test", "Topic", 9, 541 544 "due=\"2 Jun 06\" state=open", … … 556 559 AFour 557 560 EOF"; 558 use TWiki::Plugins::ActionTrackerPlugin::ActionSet;559 my $as = TWiki::Plugins::ActionTrackerPlugin::ActionSet::load(561 use Foswiki::Plugins::ActionTrackerPlugin::ActionSet; 562 my $as = Foswiki::Plugins::ActionTrackerPlugin::ActionSet::load( 560 563 "Test", "Topic", $text, 1); 561 564 … … 601 604 my $this = shift; 602 605 603 my $oaction = TWiki::Plugins::ActionTrackerPlugin::Action->new(606 my $oaction = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 604 607 "Test", "Topic", 0, 605 608 "who=JohnDoe due=\"2 Jun 02\" state=open notify=\"SamPeckinpah,QuentinTarantino\" created=\"1 Jan 1999\"", 606 609 "A new action"); 607 610 608 my $naction = TWiki::Plugins::ActionTrackerPlugin::Action->new( "Test", "Topic", 0, "who=JaneDoe due=\"2 Jun 09\" state=closed notify=\"SamPeckinpah,QuentinTarantino\" creator=\"ThomasMoore\"", "A new action<p>with more text");611 my $naction = Foswiki::Plugins::ActionTrackerPlugin::Action->new( "Test", "Topic", 0, "who=JaneDoe due=\"2 Jun 09\" state=closed notify=\"SamPeckinpah,QuentinTarantino\" creator=\"ThomasMoore\"", "A new action<p>with more text"); 609 612 610 613 my $s = "|\$who|\$due|\$state|\$creator|\$created|\$text|"; 611 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(614 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 612 615 $s,$s,"cols",$s,"\$who,\$due,\$state,\$created,\$creator,\$text"); 613 616 my %not = (); … … 615 618 my $text = $not{"$this->{users_web}.SamPeckinpah"}{text}; 616 619 $this->assert_matches( 617 qr/\|$this->{users_web}.JaneDoe\| Tue,2 Jun 2009\|closed\|$this->{users_web}.ThomasMoore\|/,620 qr/\|$this->{users_web}.JaneDoe\|2 Jun 2009\|closed\|$this->{users_web}.ThomasMoore\|/, 618 621 $text); 619 622 $this->assert_matches(qr/\|A new action<p>with more text\|/, $text); … … 621 624 qr/Attribute \"state\" changed, was \"open\", now \"closed\"/, $text); 622 625 $this->assert_matches( 623 qr/Attribute \"due\" changed, was \" Sun, 2 Jun 2002\", now \"Tue,2 Jun 2009\"/,626 qr/Attribute \"due\" changed, was \"2 Jun 2002\", now \"2 Jun 2009\"/, 624 627 $text); 625 628 $this->assert_matches( … … 627 630 $text); 628 631 $this->assert_matches( 629 qr/Attribute \"created\" was \" Fri,1 Jan 1999\" now removed/,632 qr/Attribute \"created\" was \"1 Jan 1999\" now removed/, 630 633 $text); 631 634 $this->assert_matches( … … 640 643 $text); 641 644 $this->assert_html_matches( 642 "<tr class=\"atpChanges\"><td class=\"atpChanges\">due</td><td class=\"atpChanges\"><span class=\"atpOpen\"> Sun, 02 Jun 2002</span></td><td class=\"atpChanges\"><span class=\"atpClosed\">Tue,02 Jun 2009</span></td></tr>",645 "<tr class=\"atpChanges\"><td class=\"atpChanges\">due</td><td class=\"atpChanges\"><span class=\"atpOpen\">02 Jun 2002</span></td><td class=\"atpChanges\"><span class=\"atpClosed\">02 Jun 2009</span></td></tr>", 643 646 $text); 644 647 $this->assert_html_matches( … … 646 649 $text); 647 650 $this->assert_html_matches( 648 "<tr class=\"atpChanges\"><td class=\"atpChanges\">created</td><td class=\"atpChanges\"> Fri,01 Jan 1999</td><td class=\"atpChanges\"> *removed* </td></tr>",651 "<tr class=\"atpChanges\"><td class=\"atpChanges\">created</td><td class=\"atpChanges\">01 Jan 1999</td><td class=\"atpChanges\"> *removed* </td></tr>", 649 652 $text); 650 653 $this->assert_html_matches( … … 659 662 my $this = shift; 660 663 661 my $s = TWiki::Plugins::ActionTrackerPlugin::Action::extendTypes(664 my $s = Foswiki::Plugins::ActionTrackerPlugin::Action::extendTypes( 662 665 "| plaintiffs,names,16| decision, text, 16|sentencing,date|sentence,select,17,life,\"5 years\",\"community service\"|"); 663 666 $this->assert(!defined($s), $s); 664 667 665 my $action = TWiki::Plugins::ActionTrackerPlugin::Action->new(668 my $action = Foswiki::Plugins::ActionTrackerPlugin::Action->new( 666 669 "Test", "Topic", 0, 667 670 'who=JohnDoe due="2002-06-02" state=open,plaintiffs="fred.bloggs@limp.net,JoeShmoe",decision="cut off their heads" sentencing=2-mar-2006 sentence="5 years"', … … 675 678 $s =~ s/ plaintiffs="fred.bloggs\@limp.net, $this->{users_web}.JoeShmoe"//o; 676 679 $s =~ s/ decision="cut off their heads"//o; 677 $s =~ s/ who="$this->{users_web}\.$ TWiki::cfg{DefaultUserWikiName}"//o;680 $s =~ s/ who="$this->{users_web}\.$Foswiki::cfg{DefaultUserWikiName}"//o; 678 681 $s =~ s/ sentencing="2006-03-02"//o; 679 682 $s =~ s/ sentence="5 years"//o; 680 683 $this->assert_str_equals("%ACTION{ }% %ENDACTION%", $s); 681 684 682 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(685 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 683 686 "", "|\$plaintiffs|","","\$plaintiffs"); 684 687 $s = $fmt->formatStringTable([$action]); … … 688 691 qr/<td>fred.bloggs\@limp.net, $this->{users_web}.JoeShmoe<\/td>/, $s ); 689 692 690 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(693 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 691 694 "", "|\$decision|","","\$decision"); 692 695 $s = $fmt->formatStringTable([$action]); … … 695 698 $this->assert_matches(qr/<td>cut off their heads<\/td>/, $s ); 696 699 697 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(700 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 698 701 "", "|\$sentence|","","\$sentence"); 699 702 $s = $fmt->formatStringTable([$action]); … … 702 705 $this->assert_matches(qr/<td>5 years<\/td>/, $s ); 703 706 704 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(707 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 705 708 "", "","","\$sentencing"); 706 709 $s = $fmt->formatStringTable([$action]); 707 $this->assert_str_equals(" Thu,02 Mar 2006\n", $s);708 709 my $attrs = TWiki::Attrs->new("sentence=\"5 years\"");710 $this->assert($action->matches($attrs)); 711 $attrs = TWiki::Attrs->new("sentence=\"life\"");712 $this->assert(!$action->matches($attrs)); 713 $attrs = TWiki::Attrs->new("sentence=\"\\d+ years\"");714 $this->assert($action->matches($attrs)); 715 716 $s = TWiki::Plugins::ActionTrackerPlugin::Action::extendTypes(710 $this->assert_str_equals("02 Mar 2006\n", $s); 711 712 my $attrs = Foswiki::Attrs->new("sentence=\"5 years\""); 713 $this->assert($action->matches($attrs)); 714 $attrs = Foswiki::Attrs->new("sentence=\"life\""); 715 $this->assert(!$action->matches($attrs)); 716 $attrs = Foswiki::Attrs->new("sentence=\"\\d+ years\""); 717 $this->assert($action->matches($attrs)); 718 719 $s = Foswiki::Plugins::ActionTrackerPlugin::Action::extendTypes( 717 720 "|state,select,17,life,\"5 years\",\"community service\"|"); 718 721 $this->assert(!defined($s),$s); 719 TWiki::Plugins::ActionTrackerPlugin::Action::unextendTypes();720 $s = TWiki::Plugins::ActionTrackerPlugin::Action::extendTypes(722 Foswiki::Plugins::ActionTrackerPlugin::Action::unextendTypes(); 723 $s = Foswiki::Plugins::ActionTrackerPlugin::Action::extendTypes( 721 724 "|who,text,17|"); 722 725 $this->assert_str_equals( 723 726 'Attempt to redefine attribute \'who\' in EXTRAS',$s); 724 $s = TWiki::Plugins::ActionTrackerPlugin::Action::extendTypes("|fleegle|");727 $s = Foswiki::Plugins::ActionTrackerPlugin::Action::extendTypes("|fleegle|"); 725 728 $this->assert_str_equals("Bad EXTRAS definition 'fleegle' in EXTRAS",$s ); 726 TWiki::Plugins::ActionTrackerPlugin::Action::unextendTypes();729 Foswiki::Plugins::ActionTrackerPlugin::Action::unextendTypes(); 727 730 } 728 731 … … 757 760 $query->param( ACTION_NUMBER=> -99); 758 761 my $action = 759 TWiki::Plugins::ActionTrackerPlugin::Action::createFromQuery(762 Foswiki::Plugins::ActionTrackerPlugin::Action::createFromQuery( 760 763 "Web","Topic",10,$query); 761 764 my $chosen = $action->stringify(); … … 776 779 777 780 my $action = 778 new TWiki::Plugins::ActionTrackerPlugin::Action(781 new Foswiki::Plugins::ActionTrackerPlugin::Action( 779 782 "Web", "Topic", 9, 780 783 'state="open" creator="$this->{users_web}.Creator" notify="$this->{users_web}.Notifyee" closer="$this->{users_web}.Closer" due="4-May-2003" closed="2-May-2003" who="$this->{users_web}.Who" created="3-May-2003" uid="UID"', 781 784 "Text"); 782 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format( "|Who|", "|\$who|", "cols","","");785 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( "|Who|", "|\$who|", "cols","",""); 783 786 my $s = $action->formatForEdit($fmt); 784 787 # only the who field should be a text; the rest should be hiddens … … 797 800 $s =~ s(<input (.*?name="due".*?)/>)(); 798 801 $this->assert_matches(qr/type="hidden"/, $1); 799 $this->assert_matches(qr/value=" Sun,4 May 2003"/, $1);802 $this->assert_matches(qr/value="4 May 2003"/, $1); 800 803 $s =~ s(<input (.*?name="closed".*?)/>)(); 801 804 $this->assert_matches(qr/type="hidden"/, $1); 802 $this->assert_matches(qr/value=" Fri,2 May 2003"/, $1);805 $this->assert_matches(qr/value="2 May 2003"/, $1); 803 806 $s =~ s(<input (.*?name="created".*?)/>)(); 804 807 $this->assert_matches(qr/type="hidden"/, $1); 805 $this->assert_matches(qr/value=" Sat,3 May 2003"/, $1);808 $this->assert_matches(qr/value="3 May 2003"/, $1); 806 809 $s =~ s(<input (.*?name="uid".*?)/>)(); 807 810 $this->assert_matches(qr/type="hidden"/, $1); … … 815 818 816 819 my $action = 817 new TWiki::Plugins::ActionTrackerPlugin::Action(820 new Foswiki::Plugins::ActionTrackerPlugin::Action( 818 821 "Web", "Topic", 9, 819 822 "state=\"open\" creator=\"$this->{users_web}.Creator\" notify=\"$this->{users_web}.Notifyee\" closer=\"$this->{users_web}.Closer\" due=\"4-May-2003\" closed=\"2-May-2003\" who=\"$this->{users_web}.Who\" created=\"3-May-2003\" uid=\"UID\"", … … 826 829 $bods =~ s/(\w+)/\$$1/go; 827 830 828 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format(831 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( 829 832 $all, $bods, "",""); 830 833 my $s = $action->formatForEdit($fmt); … … 841 844 foreach my $n (split(/\|/,$expand)) { 842 845 $this->assert($s =~ s(<th>$n<\/th>)(), $n); 843 require TWiki::Contrib::JSCalendarContrib;846 require Foswiki::Contrib::JSCalendarContrib; 844 847 if (!$@ && ($n eq "closed" || $n eq "due" || $n eq "created")) { 845 848 $this->assert( … … 862 865 } 863 866 } 864 $this->assert($s =~ s/^\s*<table class="atp Edit">//);867 $this->assert($s =~ s/^\s*<table class="atpSearch">//, $s); 865 868 $this->assert($s =~ s/\s*<tr><\/tr>//, $s); 866 869 $this->assert($s =~ s/\s*<tr>//); … … 876 879 877 880 $action = 878 new TWiki::Plugins::ActionTrackerPlugin::Action(881 new Foswiki::Plugins::ActionTrackerPlugin::Action( 879 882 "Web", "Topic", 9, 880 883 "state=\"open\" due=\"4-May-2001\"", "Test"); 881 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002");882 $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format( "|Due|", "|\$due|", "","");884 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 885 $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( "|Due|", "|\$due|", "",""); 883 886 $s = $action->formatForEdit($fmt); 884 887 $s =~ /value=\"(.*?)\"/; 885 $this->assert_str_equals($1, " Fri,04 May 2001");888 $this->assert_str_equals($1, "04 May 2001"); 886 889 } 887 890 … … 889 892 my $this = shift; 890 893 891 my $s = TWiki::Plugins::ActionTrackerPlugin::Action::extendTypes("|state,select,17,life,\"5 years\",\"community service\"|");894 my $s = Foswiki::Plugins::ActionTrackerPlugin::Action::extendTypes("|state,select,17,life,\"5 years\",\"community service\"|"); 892 895 $this->assert(!defined($s)); 893 896 my $action = 894 new TWiki::Plugins::ActionTrackerPlugin::Action("Web", "Topic", 10,897 new Foswiki::Plugins::ActionTrackerPlugin::Action("Web", "Topic", 10, 895 898 "state=\"5 years\"", "Text"); 896 my $fmt = new TWiki::Plugins::ActionTrackerPlugin::Format( "|State|", "|\$state|", "","");899 my $fmt = new Foswiki::Plugins::ActionTrackerPlugin::Format( "|State|", "|\$state|", "",""); 897 900 $s = $action->formatForEdit($fmt); 898 901 $s =~ s((<option value="life">life</option>))(); … … 912 915 $s =~ s/\s+//go; 913 916 $this->assert_str_equals("State", $s); 914 TWiki::Plugins::ActionTrackerPlugin::Action::unextendTypes();917 Foswiki::Plugins::ActionTrackerPlugin::Action::unextendTypes(); 915 918 } 916 919 … … 920 923 921 924 my $action = 922 new TWiki::Plugins::ActionTrackerPlugin::Action(925 new Foswiki::Plugins::ActionTrackerPlugin::Action( 923 926 "Test", "Topic", 0, 924 927 'who="SlyStallone" state=open ', 925 928 "A new action"); 926 929 927 my $attrs = new TWiki::Attrs("who=$this->{users_web}.SlyStallone",1);928 $this->assert($action->matches($attrs)); 929 $attrs = new TWiki::Attrs('state="open"',1);930 $this->assert($action->matches($attrs)); 931 932 $attrs = new TWiki::Attrs("late",1);933 $this->assert($action->matches($attrs)); 934 935 $attrs = new TWiki::Attrs("within='+1'",1);936 $this->assert(!$action->matches($attrs)); 937 $attrs = new TWiki::Attrs("within='1'",1);938 $this->assert($action->matches($attrs)); 939 940 TWiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002");941 $attrs = new TWiki::Attrs('due="31 May 02"',1);930 my $attrs = new Foswiki::Attrs("who=$this->{users_web}.SlyStallone",1); 931 $this->assert($action->matches($attrs)); 932 $attrs = new Foswiki::Attrs('state="open"',1); 933 $this->assert($action->matches($attrs)); 934 935 $attrs = new Foswiki::Attrs("late",1); 936 $this->assert($action->matches($attrs)); 937 938 $attrs = new Foswiki::Attrs("within='+1'",1); 939 $this->assert(!$action->matches($attrs)); 940 $attrs = new Foswiki::Attrs("within='1'",1); 941 $this->assert($action->matches($attrs)); 942 943 Foswiki::Plugins::ActionTrackerPlugin::Action::forceTime("31 May 2002"); 944 $attrs = new Foswiki::Attrs('due="31 May 02"',1); 942 945 $this->assert($action->matches($attrs)); 943 946 }
Note: See TracChangeset
for help on using the changeset viewer.
