Changeset 13794
- Timestamp:
- 01/23/12 07:00:46 (4 weeks ago)
- Location:
- branches/Release01x01/UnitTestContrib/test/unit
- Files:
-
- 39 edited
-
AccessControlTests.pm (modified) (43 diffs)
-
AttrsTests.pm (modified) (1 diff)
-
CacheTests.pm (modified) (9 diffs)
-
ClientTests.pm (modified) (13 diffs)
-
ConfigureTests.pm (modified) (3 diffs)
-
EmptyTests.pm (modified) (8 diffs)
-
ExceptionTests.pm (modified) (10 diffs)
-
Fn_GROUPINFO.pm (modified) (11 diffs)
-
Fn_IF.pm (modified) (150 diffs)
-
Fn_REVINFO.pm (modified) (31 diffs)
-
Fn_VAR.pm (modified) (3 diffs)
-
FormDefTests.pm (modified) (1 diff)
-
FoswikiPmFunctionsTests.pm (modified) (6 diffs)
-
FuncTests.pm (modified) (4 diffs)
-
FuncUsersTests.pm (modified) (42 diffs)
-
HTMLValidationTests.pm (modified) (13 diffs)
-
HierarchicalWebsTests.pm (modified) (26 diffs)
-
ManageDotPmTests.pm (modified) (66 diffs)
-
MergeTests.pm (modified) (12 diffs)
-
MetaTests.pm (modified) (59 diffs)
-
PasswordTests.pm (modified) (35 diffs)
-
PluginHandlerTests.pm (modified) (34 diffs)
-
RESTTests.pm (modified) (21 diffs)
-
RegisterTests.pm (modified) (87 diffs)
-
RenameTests.pm (modified) (3 diffs)
-
RobustnessTests.pm (modified) (4 diffs)
-
SaveScriptTests.pm (modified) (100 diffs)
-
SemiAutomaticTestCaseTests.pm (modified) (7 diffs)
-
StoreTests.pm (modified) (55 diffs)
-
TemplatesTests.pm (modified) (31 diffs)
-
UIFnCompileTests.pm (modified) (11 diffs)
-
UploadScriptTests.pm (modified) (12 diffs)
-
VCMetaTests.pm (modified) (22 diffs)
-
VCStoreTests.pm (modified) (35 diffs)
-
VariableTests.pm (modified) (9 diffs)
-
ViewFileScriptTests.pm (modified) (21 diffs)
-
ViewParamSectionTests.pm (modified) (8 diffs)
-
ViewScriptTests.pm (modified) (11 diffs)
-
ZoneTests.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x01/UnitTestContrib/test/unit/AccessControlTests.pm
r13729 r13794 3 3 use warnings; 4 4 5 use FoswikiFnTestCase ;5 use FoswikiFnTestCase(); 6 6 our @ISA = qw( FoswikiFnTestCase ); 7 7 … … 41 41 $this->SUPER::set_up(); 42 42 43 my $topicObject = Foswiki::Meta->new( 44 $this->{session}, 45 $Foswiki::cfg{UsersWebName}, 46 $Foswiki::cfg{DefaultUserWikiName}, '' 47 ); 48 $topicObject->save(); 43 my ($topicObject) = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, 44 $Foswiki::cfg{DefaultUserWikiName} ); 45 $topicObject->text(''); 46 $topicObject->save(); 47 $topicObject->finish(); 49 48 $this->registerUser( 'white', 'Mr', "White", 'white@example.com' ); 50 49 $MrWhite = $this->{session}->{users}->getCanonicalUserID('white'); … … 58 57 $MrYellow = $this->{session}->{users}->getCanonicalUserID('yellow'); 59 58 60 $topicObject = 61 Foswiki::Meta->new( $this->{session}, $this->{users_web}, 62 "ReservoirDogsGroup", <<"THIS"); 59 $this->createNewFoswikiSession(); 60 ($topicObject) = 61 Foswiki::Func::readTopic( $this->{users_web}, "ReservoirDogsGroup" ); 62 $topicObject->text(<<"THIS"); 63 63 * Set GROUP = MrWhite, $this->{users_web}.MrBlue 64 64 THIS 65 65 $topicObject->save(); 66 67 return; 68 } 69 70 sub tear_down { 71 my $this = shift; 72 $this->SUPER::tear_down(); 66 $topicObject->finish(); 73 67 74 68 return; … … 79 73 $web ||= $this->{test_web}; 80 74 $topic ||= $this->{test_topic}; 81 my $topicObject = Foswiki::Meta->load( $this->{session},$web, $topic );75 my ($topicObject) = Foswiki::Func::readTopic( $web, $topic ); 82 76 $this->assert( !$topicObject->haveAccess( $mode, $user ), 83 77 "$user $mode $web.$topic" ); … … 106 100 ); 107 101 } 102 $topicObject->finish(); 108 103 109 104 return; … … 114 109 $web ||= $this->{test_web}; 115 110 $topic ||= $this->{test_topic}; 116 my $topicObject = Foswiki::Meta->load( $this->{session},$web, $topic );111 my ($topicObject) = Foswiki::Func::readTopic( $web, $topic ); 117 112 $this->assert( $topicObject->haveAccess( $mode, $user ), 118 113 "$user $mode $web.$topic" ); … … 141 136 ); 142 137 } 138 $topicObject->finish(); 143 139 144 140 return; … … 152 148 sub test_denytopic { 153 149 my $this = shift; 154 my $topicObject=155 Foswiki:: Meta->new( $this->{session}, $this->{test_web},156 $this->{test_topic},<<"THIS");150 my ($topicObject) = 151 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 152 $topicObject->text(<<"THIS"); 157 153 If DENYTOPIC is set to a list of wikinames 158 154 * people in the list will be DENIED. … … 161 157 THIS 162 158 $topicObject->save(); 163 164 $this->{session}->finish(); 165 $this->{session} = Foswiki->new(); 166 159 $topicObject->finish(); 160 161 $this->createNewFoswikiSession(); 167 162 $this->PERMITTED( "VIEW", $MrGreen ); 168 163 $this->DENIED( "VIEW", $MrYellow ); … … 177 172 sub test_empty_denytopic { 178 173 my $this = shift; 179 my $topicObject=180 Foswiki:: Meta->new( $this->{session}, $this->{test_web},181 $this->{test_topic},<<'THIS');174 my ($topicObject) = 175 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 176 $topicObject->text(<<'THIS'); 182 177 If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 183 178 * access is PERMITTED _i.e _ no-one is denied access to this topic … … 185 180 THIS 186 181 $topicObject->save(); 187 188 $this->{session}->finish(); 189 $this-> {session} = Foswiki->new();182 $topicObject->finish(); 183 184 $this->createNewFoswikiSession(); 190 185 $this->PERMITTED( "VIEW", $MrGreen ); 191 186 $this->PERMITTED( "VIEW", $MrYellow ); … … 200 195 sub test_whitespace_denytopic { 201 196 my $this = shift; 202 my $topicObject=203 Foswiki:: Meta->new( $this->{session}, $this->{test_web},204 $this->{test_topic},<<'THIS');197 my ($topicObject) = 198 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 199 $topicObject->text(<<'THIS'); 205 200 If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 206 201 * access is PERMITTED _i.e _ no-one is denied access to this topic … … 208 203 THIS 209 204 $topicObject->save(); 210 211 $this->{session}->finish(); 212 $this-> {session} = Foswiki->new();205 $topicObject->finish(); 206 207 $this->createNewFoswikiSession(); 213 208 $this->PERMITTED( "VIEW", $MrGreen ); 214 209 $this->PERMITTED( "VIEW", $MrYellow ); … … 223 218 sub test_denytopic_whitespace { 224 219 my $this = shift; 225 my $topicObject=226 Foswiki:: Meta->new( $this->{session}, $this->{test_web},227 $this->{test_topic},<<'THIS');220 my ($topicObject) = 221 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 222 $topicObject->text(<<'THIS'); 228 223 If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 229 224 * access is PERMITTED _i.e _ no-one is denied access to this topic … … 231 226 THIS 232 227 $topicObject->save(); 233 234 $this->{session}->finish(); 235 $this-> {session} = Foswiki->new();228 $topicObject->finish(); 229 230 $this->createNewFoswikiSession(); 236 231 $this->PERMITTED( "VIEW", $MrGreen ); 237 232 $this->PERMITTED( "VIEW", $MrYellow ); … … 246 241 sub test_allowtopic { 247 242 my $this = shift; 248 my $topicObject=249 Foswiki:: Meta->new( $this->{session}, $this->{test_web},250 $this->{test_topic},<<'THIS');243 my ($topicObject) = 244 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 245 $topicObject->text(<<'THIS'); 251 246 If ALLOWTOPIC is set 252 247 1. people in the list are PERMITTED … … 255 250 THIS 256 251 $topicObject->save(); 257 258 $this->{session}->finish(); 259 $this-> {session} = Foswiki->new();252 $topicObject->finish(); 253 254 $this->createNewFoswikiSession(); 260 255 $this->PERMITTED( "VIEW", $MrOrange ); 261 256 $this->DENIED( "VIEW", $MrGreen ); … … 271 266 sub test_allowtopic_a { 272 267 my $this = shift; 273 my $topicObject=274 Foswiki:: Meta->new( $this->{session}, $this->{test_web},275 $this->{test_topic},<<'THIS');268 my ($topicObject) = 269 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 270 $topicObject->text(<<'THIS'); 276 271 If ALLOWTOPIC is set 277 272 1. people in the list are PERMITTED … … 280 275 THIS 281 276 $topicObject->save(); 277 $topicObject->finish(); 282 278 283 279 my $topicquery = Unit::Request->new(""); … … 285 281 286 282 # renew Foswiki, so WebPreferences gets re-read 287 $this->{session}->finish(); 288 $this->{session} = Foswiki->new( undef, $topicquery ); 283 $this->createNewFoswikiSession(); 289 284 $this->PERMITTED( "VIEW", $MrOrange ); 290 $this->{session}->finish(); 291 $this->{session} = Foswiki->new( undef, $topicquery ); 285 $this->createNewFoswikiSession( undef, $topicquery ); 292 286 $this->DENIED( "VIEW", $MrGreen ); 293 $this->{session}->finish(); 294 $this->{session} = Foswiki->new( undef, $topicquery ); 287 $this->createNewFoswikiSession( undef, $topicquery ); 295 288 $this->DENIED( "VIEW", $MrYellow ); 296 $this->{session}->finish(); 297 $this->{session} = Foswiki->new( undef, $topicquery ); 289 $this->createNewFoswikiSession( undef, $topicquery ); 298 290 $this->DENIED( "VIEW", $MrWhite ); 299 $this->{session}->finish(); 300 $this->{session} = Foswiki->new( undef, $topicquery ); 291 $this->createNewFoswikiSession( undef, $topicquery ); 301 292 $this->DENIED( "view", $MrBlue ); 302 293 … … 309 300 sub test_allowtopic_b { 310 301 my $this = shift; 311 my $topicObject=312 Foswiki:: Meta->new( $this->{session}, $this->{test_web},313 $this->{test_topic},<<'THIS');302 my ($topicObject) = 303 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 304 $topicObject->text(<<'THIS'); 314 305 If ALLOWTOPIC is set 315 306 1. people in the list are PERMITTED … … 318 309 THIS 319 310 $topicObject->save(); 311 $topicObject->finish(); 320 312 321 313 # renew Foswiki, so WebPreferences gets re-read 322 $this->{session}->finish(); 323 $this->{session} = Foswiki->new(); 314 $this->createNewFoswikiSession(); 324 315 $this->PERMITTED( "VIEW", $MrOrange ); 325 $this->{session}->finish(); 326 $this->{session} = Foswiki->new(); 316 $this->createNewFoswikiSession(); 327 317 $this->DENIED( "VIEW", $MrGreen ); 328 $this->{session}->finish(); 329 $this->{session} = Foswiki->new(); 318 $this->createNewFoswikiSession(); 330 319 $this->DENIED( "VIEW", $MrYellow ); 331 $this->{session}->finish(); 332 $this->{session} = Foswiki->new(); 320 $this->createNewFoswikiSession(); 333 321 $this->DENIED( "VIEW", $MrWhite ); 334 $this->{session}->finish(); 335 $this->{session} = Foswiki->new(); 322 $this->createNewFoswikiSession(); 336 323 $this->DENIED( "view", $MrBlue ); 337 324 … … 343 330 sub test_allowtopic_c { 344 331 my $this = shift; 345 my $topicObject=346 Foswiki:: Meta->new( $this->{session}, $this->{test_web},347 $this->{test_topic},<<'THIS');332 my ($topicObject) = 333 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 334 $topicObject->text(<<'THIS'); 348 335 If ALLOWTOPIC is set 349 336 1. people in the list are PERMITTED … … 360 347 ); 361 348 $topicObject->save(); 349 $topicObject->finish(); 362 350 363 351 # renew Foswiki, so WebPreferences gets re-read 364 $this->{session}->finish(); 365 $this->{session} = Foswiki->new(); 352 $this->createNewFoswikiSession(); 366 353 $this->PERMITTED( "VIEW", $MrOrange ); 367 $this->{session}->finish(); 368 $this->{session} = Foswiki->new(); 354 $this->createNewFoswikiSession(); 369 355 $this->DENIED( "VIEW", $MrGreen ); 370 $this->{session}->finish(); 371 $this->{session} = Foswiki->new(); 356 $this->createNewFoswikiSession(); 372 357 $this->PERMITTED( "VIEW", $MrYellow ); 373 $this->{session}->finish(); 374 $this->{session} = Foswiki->new(); 358 $this->createNewFoswikiSession(); 375 359 $this->DENIED( "VIEW", $MrWhite ); 376 $this->{session}->finish(); 377 $this->{session} = Foswiki->new(); 360 $this->createNewFoswikiSession(); 378 361 $this->DENIED( "view", $MrBlue ); 379 362 … … 384 367 sub test_denyweb { 385 368 my $this = shift; 386 my $topicObject = 387 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 388 $Foswiki::cfg{WebPrefsTopicName}, <<"THIS"); 369 my ($topicObject) = 370 Foswiki::Func::readTopic( $this->{test_web}, 371 $Foswiki::cfg{WebPrefsTopicName} ); 372 $topicObject->text(<<"THIS"); 389 373 If DENYWEB is set to a list of wikiname 390 374 * people in the list are DENIED access … … 392 376 THIS 393 377 $topicObject->save(); 378 $topicObject->finish(); 394 379 395 380 # renew Foswiki, so WebPreferences gets re-read 396 $this-> {session}->finish();397 $this->{session} = Foswiki->new();398 $topicObject = Foswiki::Meta->new(399 $this->{session}, $this->{test_web},400 $this->{test_topic}, "Null points"401 );402 $topicObject->save(); 381 $this->createNewFoswikiSession(); 382 ($topicObject) = 383 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 384 $topicObject->text("Null points"); 385 $topicObject->save(); 386 $topicObject->finish(); 387 403 388 $this->DENIED( "VIEW", $MrOrange ); 404 389 $this->PERMITTED( "VIEW", $MrGreen ); … … 412 397 # Test that ALLOWWEB works in a top-level web with no finalisation 413 398 sub test_allow_web { 414 my $this = shift; 415 my $topicObject = Foswiki::Meta->new( 416 $this->{session}, 417 $this->{test_web}, $Foswiki::cfg{WebPrefsTopicName}, 399 my $this = shift; 400 my ($topicObject) = 401 Foswiki::Func::readTopic( $this->{test_web}, 402 $Foswiki::cfg{WebPrefsTopicName} ); 403 $topicObject->text( 418 404 <<'THIS' 419 405 If ALLOWWEB is set to a list of wikinames … … 422 408 * Set ALLOWWEBVIEW = MrGreen MrYellow MrWhite 423 409 THIS 424 , undef425 );426 $topicObject-> save();410 ); 411 $topicObject->save(); 412 $topicObject->finish(); 427 413 428 414 # renew Foswiki, so WebPreferences gets re-read 429 $this->{session}->finish(); 430 $this->{session} = Foswiki->new(); 431 $topicObject = Foswiki::Meta->new( 432 $this->{session}, $this->{test_web}, 433 $this->{test_topic}, "Null points" 434 ); 435 $topicObject->save(); 415 $this->createNewFoswikiSession(); 416 ($topicObject) = 417 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 418 $topicObject->text("Null points"); 419 $topicObject->save(); 420 $topicObject->finish(); 436 421 $this->DENIED( "VIEW", $MrOrange ); 437 422 $this->PERMITTED( "VIEW", $MrGreen ); … … 445 430 # Test that Web.UserName is equivalent to UserName in ACLs 446 431 sub test_webDotUserName { 447 my $this = shift; 448 my $topicObject = Foswiki::Meta->new( 449 $this->{session}, $this->{test_web}, $this->{test_topic}, 432 my $this = shift; 433 my ($topicObject) = 434 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 435 $topicObject->text( 450 436 <<'THIS' 451 437 If ALLOWTOPIC is set … … 454 440 * Set ALLOWTOPICVIEW = MrYellow,%USERSWEB%.MrOrange,Nosuchweb.MrGreen,%MAINWEB%.MrBlue,%SYSTEMWEB%.MrWhite 455 441 THIS 456 , undef 457 ); 458 $topicObject->save(); 459 $this->{session}->finish(); 460 $this->{session} = Foswiki->new(); 442 ); 443 $topicObject->save(); 444 $topicObject->finish(); 445 $this->createNewFoswikiSession(); 461 446 $this->PERMITTED( "VIEW", $MrOrange ); 462 447 $this->DENIED( "VIEW", $MrGreen ); … … 502 487 * Set ALLOWTOPICVIEW = %USERSWEB%.MrGreen 503 488 THIS 504 my $topicObject = 505 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 506 $this->{test_topic}, $text ); 507 $topicObject->save(); 508 $this->{session}->finish(); 509 510 $this->{session} = Foswiki->new(); 511 $topicObject = 512 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 513 $this->{test_topic} ); 489 my ($topicObject) = 490 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 491 $topicObject->text($text); 492 $topicObject->save(); 493 $topicObject->finish(); 494 $this->createNewFoswikiSession(); 495 496 ($topicObject) = 497 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 514 498 $this->_checkSettings($topicObject); 499 $topicObject->finish(); 515 500 516 501 return; … … 521 506 my $this = shift; 522 507 523 my $topicObject=524 Foswiki:: Meta->new( $this->{session}, $this->{test_web},525 $this->{test_topic}, 'Empty');508 my ($topicObject) = 509 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 510 $topicObject->text('Empty'); 526 511 my $args = { 527 512 name => 'ALLOWTOPICVIEW', … … 532 517 $topicObject->putKeyed( 'PREFERENCE', $args ); 533 518 $topicObject->save(); 534 $this->{session}->finish(); 535 536 $this->{session} = Foswiki->new(); 537 $topicObject = 538 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 539 $this->{test_topic} ); 519 $topicObject->finish(); 520 $this->createNewFoswikiSession(); 521 522 ($topicObject) = 523 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 540 524 541 525 $this->_checkSettings($topicObject); 526 $topicObject->finish(); 542 527 543 528 return; … … 551 536 * Set ALLOWTOPICVIEW = %USERSWEB%.MrOrange 552 537 THIS 553 my $topicObject=554 Foswiki:: Meta->new( $this->{session}, $this->{test_web},555 $this->{test_topic}, $text);538 my ($topicObject) = 539 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 540 $topicObject->text($text); 556 541 my $args = { 557 542 name => 'ALLOWTOPICVIEW', … … 562 547 $topicObject->putKeyed( 'PREFERENCE', $args ); 563 548 $topicObject->save(); 564 $this->{session}->finish(); 565 566 $this->{session} = Foswiki->new(); 567 $topicObject = 568 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 569 $this->{test_topic} ); 549 $topicObject->finish(); 550 $this->createNewFoswikiSession(); 551 552 ($topicObject) = 553 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 570 554 $this->_checkSettings($topicObject); 555 $topicObject->finish(); 571 556 572 557 return; … … 581 566 582 567 # First build a parent web with view restricted to MrGreen 583 my $topicObject = 584 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 585 $this->{test_topic}, "Nowt" ); 586 $topicObject->save(); 587 588 $topicObject = 589 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 590 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 568 my ($topicObject) = 569 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 570 $topicObject->text("Nowt"); 571 $topicObject->save(); 572 $topicObject->finish(); 573 574 ($topicObject) = 575 Foswiki::Func::readTopic( $this->{test_web}, 576 $Foswiki::cfg{WebPrefsTopicName} ); 577 $topicObject->text(<<'THIS'); 591 578 * Set ALLOWWEBVIEW = MrGreen 592 579 THIS 593 580 $topicObject->save(); 581 $topicObject->finish(); 594 582 595 583 # Now build a subweb with view restricted to MrOrange 596 584 my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 597 585 $webObject->populateNewWeb(); 598 $topicObject = 599 Foswiki::Meta->new( $this->{session}, $subweb, 600 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 586 $webObject->finish(); 587 ($topicObject) = 588 Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 589 $topicObject->text(<<'THIS'); 601 590 * Set ALLOWWEBVIEW = MrOrange 602 591 THIS 603 592 $topicObject->save(); 604 $t his->{session}->finish();593 $topicObject->finish(); 605 594 606 595 # Ensure that MrOrange can read the subweb and MrGreen the parent web 607 $this-> {session} = Foswiki->new();596 $this->createNewFoswikiSession(); 608 597 $this->PERMITTED( "VIEW", $MrOrange, $subweb ); 609 598 $this->DENIED( "VIEW", $MrGreen, $subweb ); … … 623 612 # First build a parent web with view restricted to MrGreen, and 624 613 # finalise the setting 625 my $topicObject = 626 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 627 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 614 my ($topicObject) = 615 Foswiki::Func::readTopic( $this->{test_web}, 616 $Foswiki::cfg{WebPrefsTopicName} ); 617 $topicObject->text(<<'THIS'); 628 618 * Set ALLOWWEBVIEW = MrGreen 629 619 * Set FINALPREFERENCES = ALLOWWEBVIEW 630 620 THIS 631 621 $topicObject->save(); 622 $topicObject->finish(); 632 623 633 624 # Now build a subweb with no restrictions 634 625 my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 635 626 $webObject->populateNewWeb(); 636 $topicObject = 637 Foswiki::Meta->new( $this->{session}, $subweb, 638 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 639 THIS 640 $topicObject->save(); 641 $this->{session}->finish(); 642 643 $this->{session} = Foswiki->new(); 627 $webObject->finish(); 628 ($topicObject) = 629 Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 630 $topicObject->text(<<'THIS'); 631 THIS 632 $topicObject->save(); 633 $topicObject->finish(); 634 635 $this->createNewFoswikiSession(); 644 636 $this->PERMITTED( "VIEW", $MrGreen, $subweb ); 645 637 $this->DENIED( "VIEW", $MrOrange, $subweb ); … … 659 651 # First build a parent web with view restricted to MrGreen, and 660 652 # finalise the setting 661 my $topicObject = 662 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 663 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 653 my ($topicObject) = 654 Foswiki::Func::readTopic( $this->{test_web}, 655 $Foswiki::cfg{WebPrefsTopicName} ); 656 $topicObject->text(<<'THIS'); 664 657 * Set ALLOWWEBVIEW = MrGreen 665 658 * Set FINALPREFERENCES = ALLOWWEBVIEW 666 659 THIS 667 660 $topicObject->save(); 661 $topicObject->finish(); 668 662 669 663 # Now build a subweb with view restricted to MrOrange 670 664 my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 671 665 $webObject->populateNewWeb(); 672 $topicObject = 673 Foswiki::Meta->new( $this->{session}, $subweb, 674 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 666 $webObject->finish(); 667 ($topicObject) = 668 Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 669 $topicObject->text(<<'THIS'); 675 670 * Set ALLOWWEBVIEW = MrOrange 676 671 THIS 677 672 $topicObject->save(); 678 $t his->{session}->finish();679 680 $this->{session} = Foswiki->new(); 673 $topicObject->finish(); 674 $this->createNewFoswikiSession(); 675 681 676 $this->DENIED( "VIEW", $MrOrange, $subweb ); 682 677 $this->PERMITTED( "VIEW", $MrGreen, $subweb ); … … 696 691 697 692 # Create a topic with an anchor, viewable only by MrYellow 698 my $topicObject = Foswiki::Meta->new(699 $this->{session}, $this->{test_web}, $test_topic,700 <<'THIS'693 my ($topicObject) = 694 Foswiki::Func::readTopic( $this->{test_web}, $test_topic ); 695 $topicObject->text(<<'THIS'); 701 696 If there is an anchor, and some access restrictions, 702 697 anchor is preserved after login. … … 704 699 * Set ALLOWTOPICVIEW = MrYellow 705 700 THIS 706 , undef 707 ); 708 $topicObject->save(); 701 $topicObject->save(); 702 $topicObject->finish(); 709 703 710 704 # Request the page with the full UI … … 720 714 my $viewUrl = 721 715 $this->{session} 722 ->getScriptUrl( '0', 'view', $this->{test_web}, $test_topic );716 ->getScriptUrl( 0, 'view', $this->{test_web}, $test_topic ); 723 717 $query->uri("$viewUrl"); 718 $this->finishFoswikiSession(); 724 719 my ($text) = $this->capture( 725 720 sub { 726 $Foswiki::Plugins::SESSION->{response} = 727 Foswiki::UI::handleRequest($query); 721 my $response = Foswiki::UI::handleRequest($query); 722 $this->createNewFoswikiSession( undef, $query ); 723 $this->{session}{response} = $response; 728 724 } 729 725 ); … … 732 728 my $loginUrl = 733 729 $this->{session} 734 ->getScriptUrl( '0', 'login', $this->{test_web}, $test_topic );730 ->getScriptUrl( 0, 'login', $this->{test_web}, $test_topic ); 735 731 736 732 # Item11121: the test doesn't tolerate ShortURLs, for example. … … 748 744 749 745 # Check the redirect contains the login url + view to this topic 750 $this->assert_matches( 751 qr#^$loginUrl.*/view/$this->{test_web}/$test_topic$#, 752 $redirect_to, 753 "Login did not redirect to a page with the proper anchor:\n" 746 my $regex = qr#^\Q$loginUrl\E.*/view/$this->{test_web}/$test_topic$#; 747 $this->assert_matches( $regex, $redirect_to, 748 "Login did not redirect to a page with the proper anchor:\n" 754 749 . "Location: $redirect_to\n" 755 . "Expected: ^$loginUrl.*\%23anchor\$" 756 ); 750 . "Expected: $regex" ); 757 751 758 752 # Get the redirected page after login -
branches/Release01x01/UnitTestContrib/test/unit/AttrsTests.pm
r13729 r13794 1 package AttrsTests; 1 2 use strict; 2 3 package AttrsTests; 4 5 use FoswikiTestCase; 3 use warnings; 4 5 use FoswikiTestCase(); 6 6 our @ISA = qw( FoswikiTestCase ); 7 7 8 use Foswiki::Attrs ;8 use Foswiki::Attrs(); 9 9 10 10 sub new { -
branches/Release01x01/UnitTestContrib/test/unit/CacheTests.pm
r13729 r13794 1 1 package CacheTests; 2 use strict; 3 use warnings; 2 4 3 use FoswikiFnTestCase ;5 use FoswikiFnTestCase(); 4 6 our @ISA = qw( FoswikiFnTestCase ); 5 7 6 use strict; 7 use Foswiki; 8 use Foswiki::Meta; 8 use Foswiki(); 9 use Foswiki::Meta(); 10 use File::Spec(); 11 use Foswiki::OopsException(); 12 use Foswiki::PageCache(); 9 13 use Error qw( :try ); 10 use Foswiki::OopsException;11 use Foswiki::PageCache;12 14 use Benchmark qw(:hireswallclock); 13 15 … … 17 19 my $this = shift; 18 20 my @page; 21 19 22 foreach my $dir (@INC) { 20 if ( opendir( D, "$dir/Foswiki/Cache" ) ) { 21 foreach my $alg ( readdir D ) { 23 if ( opendir( my $D, File::Spec->catdir( $dir, 'Foswiki', 'Cache' ) ) ) 24 { 25 foreach my $alg ( readdir $D ) { 22 26 next unless $alg =~ s/^(.*)\.pm$/$1/; 23 next if defined & $alg;27 next if defined &{$alg}; 24 28 $ENV{PATH} =~ /^(.*)$/ms; 25 $ENV{PATH} = $1;29 local $ENV{PATH} = $1; 26 30 ($alg) = $alg =~ /^(.*)$/ms; 27 eval "require Foswiki::Cache::$alg"; 28 if ($@) { 29 print STDERR 30 "Cannot test Foswiki::Cache::$alg\nCompilation error when trying to 'require' it\n"; 31 } 32 else { 31 32 if ( eval "require Foswiki::Cache::$alg; 1;" ) { 33 33 no strict 'refs'; 34 * $alg= sub {34 *{$alg} = sub { 35 35 my $this = shift; 36 36 $Foswiki::cfg{CacheManager} = 'Foswiki::Cache::' . $alg; … … 39 39 push( @page, $alg ); 40 40 } 41 else { 42 print STDERR 43 "Cannot test Foswiki::Cache::$alg\nCompilation error when trying to 'require' it\n"; 44 } 41 45 } 42 closedir( D);46 closedir($D); 43 47 } 44 48 } … … 50 54 sub DBFileMeta { 51 55 $Foswiki::cfg{MetaCacheManager} = 'Foswiki::Cache::DB_File'; 56 57 return; 52 58 } 53 59 54 60 sub BDBMeta { 55 61 $Foswiki::cfg{MetaCacheManager} = 'Foswiki::Cache::BDB'; 62 63 return; 56 64 } 57 65 … … 59 67 $Foswiki::cfg{HttpCompress} = 1; 60 68 $Foswiki::cfg{Cache}{Compress} = 1; 69 70 return; 61 71 } 62 72 … … 64 74 $Foswiki::cfg{HttpCompress} = 0; 65 75 $Foswiki::cfg{Cache}{Compress} = 0; 76 77 return; 66 78 } 67 79 … … 90 102 $Foswiki::cfg{Cache}{Compress} = 0; 91 103 $UI_FN ||= $this->getUIFn('view'); 92 }93 104 94 sub tear_down { 95 my $this = shift; 96 $this->SUPER::tear_down(); 105 return; 97 106 } 98 107 … … 102 111 $UI_FN ||= $this->getUIFn('view'); 103 112 104 my $query = new Unit::Request( { skin => ['none'], } );113 my $query = Unit::Request->new( { skin => ['none'], } ); 105 114 $query->path_info("/"); 106 115 $query->method('POST'); 107 116 108 my $fatwilly = new Foswiki( $this->{test_user_login}, $query );117 $this->createNewFoswikiSession( $this->{test_user_login}, $query ); 109 118 110 119 # This first request should *not* be satisfied from the cache, but 111 120 # the cache should be populated with the result. 112 my $p1start = new Benchmark();121 my $p1start = Benchmark->new(); 113 122 my ($one) = $this->capture( 114 123 sub { 115 124 no strict 'refs'; 116 & $UI_FN($fatwilly);125 &{$UI_FN}( $this->{session} ); 117 126 use strict 'refs'; 118 $Foswiki::engine->finalize( $ fatwilly->{response},119 $ fatwilly->{request} );127 $Foswiki::engine->finalize( $this->{session}{response}, 128 $this->{session}{request} ); 120 129 } 121 130 ); 122 131 123 my $p1end = new Benchmark();132 my $p1end = Benchmark->new(); 124 133 print STDERR "R1 " . timestr( timediff( $p1end, $p1start ) ) . "\n"; 125 $fatwilly->finish();126 134 127 $ fatwilly = new Foswiki( $this->{test_user_login}, $query );135 $this->createNewFoswikiSession( $this->{test_user_login}, $query ); 128 136 129 137 # This second request should be satisfied from the cache 130 my $p2start = new Benchmark();138 my $p2start = Benchmark->new(); 131 139 my ($two) = $this->capture( 132 140 sub { 133 141 no strict 'refs'; 134 & $UI_FN($fatwilly);142 &{$UI_FN}( $this->{session} ); 135 143 use strict 'refs'; 136 $Foswiki::engine->finalize( $ fatwilly->{response},137 $ fatwilly->{request} );144 $Foswiki::engine->finalize( $this->{session}{response}, 145 $this->{session}{request} ); 138 146 } 139 147 ); 140 my $p2end = new Benchmark();148 my $p2end = Benchmark->new(); 141 149 print STDERR "R2 " . timestr( timediff( $p2end, $p2start ) ) . "\n"; 142 $fatwilly->finish();143 150 144 151 # Massage the HTML for comparison … … 164 171 165 172 $this->assert_html_equals( $one, $two ); 173 174 return; 166 175 } 167 176 -
branches/Release01x01/UnitTestContrib/test/unit/ClientTests.pm
r13729 r13794 1 package ClientTests; 1 2 use strict; 2 3 package ClientTests; 3 use warnings; 4 4 5 5 # This is woefully incomplete, but it does at least check that 6 6 # LoginManager.pm compiles okay. 7 7 8 use FoswikiFnTestCase ;8 use FoswikiFnTestCase(); 9 9 our @ISA = qw( FoswikiFnTestCase ); 10 10 11 use Unit::Request; 11 use Foswiki(); 12 use Foswiki::LoginManager(); 13 use Unit::Request(); 12 14 use Error qw( :try ); 13 14 use Foswiki;15 use Foswiki::LoginManager;16 15 17 16 my $agent = $Foswiki::cfg{Register}{RegistrationAgentWikiName}; … … 29 28 my $topicObject = Foswiki::Meta->new( 30 29 $this->{session}, $this->{test_web}, 31 $this->{test_topic}, << CONSTRAINT);30 $this->{test_topic}, <<'CONSTRAINT'); 32 31 * Set ALLOWTOPICCHANGE = AdminGroup 33 32 CONSTRAINT 34 33 $topicObject->save(); 34 35 return; 35 36 } 36 37 37 38 sub TemplateLoginManager { 38 39 $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin'; 40 41 return; 39 42 } 40 43 41 44 sub ApacheLoginManager { 42 45 $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::ApacheLogin'; 46 47 return; 43 48 } 44 49 45 50 sub NoLoginManager { 46 51 $Foswiki::cfg{LoginManager} = 'none'; 52 53 return; 47 54 } 48 55 … … 51 58 $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::BaseUserMapping'; 52 59 $this->set_up_for_verify(); 60 61 return; 53 62 } 54 63 … … 57 66 $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping'; 58 67 $this->set_up_for_verify(); 68 69 return; 59 70 } 60 71 … … 70 81 my $this = shift; 71 82 72 $this->{session}->finish() if $this->{session}; 73 $this->{session} = new Foswiki( undef, new Unit::Request() ); 83 $this->createNewFoswikiSession( undef, Unit::Request->new() ); 74 84 $this->assert( $Foswiki::cfg{TempfileDir} 75 85 && -d $Foswiki::cfg{TempfileDir} ); … … 80 90 $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1; 81 91 $Foswiki::cfg{UsersWebName} = $this->{users_web}; 92 93 return; 82 94 } 83 95 … … 101 113 102 114 #print STDERR "\n------------- set_up_user (login: $userLogin) (cUID:$user_id) -----------------\n"; 115 116 return; 103 117 } 104 118 105 119 sub capture { 106 my $this = shift; 107 my ( $proc, $session ) = @_; 120 my ( $this, $proc, $session, @args ) = @_; 108 121 $session->getLoginManager()->checkAccess(); 109 $this->SUPER::capture(@_); 122 $this->SUPER::capture( $proc, $session, @args ); 123 124 return; 110 125 } 111 126 … … 118 133 119 134 #close this Foswiki session - its using the wrong mapper and login 120 $this->{session}->finish(); 121 122 $query = new Unit::Request(); 135 136 $query = Unit::Request->new(); 123 137 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 124 $this-> {session} = new Foswiki( undef, $query );138 $this->createNewFoswikiSession( undef, $query ); 125 139 126 140 $this->set_up_user(); … … 135 149 }; 136 150 137 $query = new Unit::Request();151 $query = Unit::Request->new(); 138 152 $query->path_info("/$this->{test_web}/$this->{test_topic}?breaklock=1"); 139 $this->{session}->finish(); 140 141 $this->{session} = new Foswiki( undef, $query ); 153 154 $this->createNewFoswikiSession( undef, $query ); 142 155 143 156 try { … … 156 169 }; 157 170 158 $query = new Unit::Request();171 $query = Unit::Request->new(); 159 172 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 160 $this->{session}->finish();161 173 162 174 $this->annotate("new session using $userLogin\n"); 163 175 164 $this-> {session} = new Foswiki( $userLogin, $query );176 $this->createNewFoswikiSession( $userLogin, $query ); 165 177 166 178 #clear the lease - one of the previous tests may have different usermapper & thus different user 167 179 Foswiki::Func::setTopicEditLock( $this->{test_web}, $this->{test_topic}, 168 180 0 ); 181 182 return; 169 183 } 170 184 … … 175 189 return; 176 190 } 177 $this->{session}->finish();178 191 my $secret = "a big mole on my left buttock"; 179 192 my $crypted = crypt( $secret, "12" ); 180 193 $Foswiki::cfg{Password} = $crypted; 181 194 182 my $query = new Unit::Request(195 my $query = Unit::Request->new( 183 196 { 184 197 username => [ $Foswiki::cfg{AdminUserLogin} ], … … 190 203 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 191 204 192 $this-> {session} = new Foswiki( undef, $query );205 $this->createNewFoswikiSession( undef, $query ); 193 206 $this->{session}->getLoginManager()->login( $query, $this->{session} ); 194 207 my $script = $Foswiki::cfg{LoginManager} =~ /Apache/ ? 'viewauth' : 'view'; … … 199 212 $this->assert_matches( qr/^$surly/, 200 213 $this->{session}->{response}->headers()->{Location} ); 214 215 return; 201 216 } 202 217 -
branches/Release01x01/UnitTestContrib/test/unit/ConfigureTests.pm
r13729 r13794 4 4 use warnings; 5 5 6 use FoswikiTestCase ;6 use FoswikiTestCase(); 7 7 our @ISA = qw( FoswikiTestCase ); 8 8 9 9 use Error qw( :try ); 10 use File::Temp ;10 use File::Temp(); 11 11 use FindBin; 12 12 use File::Path qw(mkpath rmtree); … … 32 32 $root =~ s|\\|/|g; 33 33 34 $this->{rootdir} = $root;35 $this->{user} = $Foswiki::cfg{AdminUserLogin};36 $this-> {session} = Foswiki->new( $this->{user} );34 $this->{rootdir} = $root; 35 $this->{user} = $Foswiki::cfg{AdminUserLogin}; 36 $this->createNewFoswikiSession( $this->{user} ); 37 37 $this->{test_web} = 'Testsystemweb1234'; 38 38 my $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web} ); 39 39 $webObject->populateNewWeb(); 40 $webObject->finish(); 40 41 $this->{trash_web} = 'Testtrashweb1234'; 41 42 $webObject = Foswiki::Meta->new( $this->{session}, $this->{trash_web} ); 42 43 $webObject->populateNewWeb(); 44 $webObject->finish(); 43 45 $this->{sandbox_web} = 'Testsandboxweb1234'; 44 46 $webObject = Foswiki::Meta->new( $this->{session}, $this->{sandbox_web} ); 45 47 $webObject->populateNewWeb(); 48 $webObject->finish(); 46 49 $this->{sandbox_subweb} = 'Testsandboxweb1234/Subweb'; 47 50 $webObject = 48 51 Foswiki::Meta->new( $this->{session}, $this->{sandbox_subweb} ); 49 52 $webObject->populateNewWeb(); 53 $webObject->finish(); 50 54 $this->{tempdir} = $Foswiki::cfg{TempfileDir} . '/test_ConfigureTests'; 51 55 rmtree( $this->{tempdir} ) … … 1926 1930 my ( $result, $err ) = $pkg->loadInstaller(); 1927 1931 1928 my $expected = << HERE;1932 my $expected = <<'HERE'; 1929 1933 I can't download http://foswiki.org/pub/Extensions/EmptyPluginx/EmptyPluginx_installer because of the following error: 1930 1934 Not Found -
branches/Release01x01/UnitTestContrib/test/unit/EmptyTests.pm
r6912 r13794 1 use strict;2 3 1 # Example test case; use this as a basis to build your own 4 2 5 3 package EmptyTests; 4 use strict; 5 use warnings; 6 6 7 7 use FoswikiTestCase; … … 10 10 use Foswiki; 11 11 use Error qw( :try ); 12 13 my $topicquery;14 12 15 13 sub set_up { … … 20 18 # You can now safely modify $Foswiki::cfg 21 19 22 $topicquery = new Unit::Request('');20 my $topicquery = Unit::Request->new(''); 23 21 $topicquery->path_info('/TestCases/WebHome'); 24 22 try { 25 $this-> {session} = new Foswiki( 'AdminUser' || '' );23 $this->createNewFoswikiSession( 'AdminUser' || '' ); 26 24 my $user = $this->{session}->{user}; 27 25 … … 32 30 Foswiki::Meta->new( $this->{session}, "Temporarytestweb1" ); 33 31 $webObject->populateNewWeb("_default"); 32 $webObject->finish(); 34 33 35 34 # Copy a system web like this: … … 37 36 Foswiki::Meta->new( $this->{session}, "Temporarysystemweb" ); 38 37 $webObject->populateNewWeb("System"); 38 $webObject->finish(); 39 39 40 40 # Create a topic like this: … … 52 52 $this->assert( 0, shift->stringify() || '' ); 53 53 }; 54 55 return; 54 56 } 55 57 … … 61 63 $this->removeWebFixture( $this->{session}, "Temporarytestweb1" ); 62 64 $this->removeWebFixture( $this->{session}, "Temporarysystemweb" ); 63 $this->{session}->finish() if $this->{session};64 65 65 66 # Always do this, and always do it last 66 67 $this->SUPER::tear_down(); 68 69 return; 67 70 } 68 71 … … 77 80 sub test_ { 78 81 my $this = shift; 82 83 return; 79 84 } 80 85 -
branches/Release01x01/UnitTestContrib/test/unit/ExceptionTests.pm
r13729 r13794 1 1 package ExceptionTests; 2 use FoswikiFnTestCase; 2 use strict; 3 use warnings; 4 5 use FoswikiFnTestCase(); 3 6 our @ISA = qw( FoswikiFnTestCase ); 4 7 5 use strict;6 7 8 use Error qw( :try ); 8 use Foswiki::OopsException ;9 use Foswiki::AccessControlException ;9 use Foswiki::OopsException(); 10 use Foswiki::AccessControlException(); 10 11 11 12 my $UI_FN; … … 15 16 $this->SUPER::set_up(); 16 17 $UI_FN ||= $this->getUIFn('oops'); 18 19 return; 17 20 } 18 21 … … 44 47 ); 45 48 }; 49 50 return; 46 51 } 47 52 … … 70 75 ); 71 76 }; 77 78 return; 72 79 } 73 80 74 81 sub upchuck { 75 82 my $session = shift; 76 my $e = new Foswiki::OopsException(83 my $e = Foswiki::OopsException->new( 77 84 'templatename', 78 85 web => 'webname', … … 81 88 ); 82 89 $e->redirect($session); 90 91 return; 83 92 } 84 93 … … 86 95 sub deprecated_test_redirectOopsException { 87 96 my $this = shift; 88 my $t = new Foswiki(); 89 my ($output) = $this->capture( \&upchuck, $t ); 90 $t->finish(); 97 $this->createNewFoswikiSession(); 98 my ($output) = $this->capture( \&upchuck, $this->{session} ); 91 99 $this->assert_matches( qr/^Status: 302.*$/m, $output ); 92 100 $this->assert_matches( … … 94 102 $output 95 103 ); 104 105 return; 96 106 } 97 107 98 108 sub test_AccessControlException { 99 109 my $this = shift; 100 my $ace = new Foswiki::AccessControlException( 'FRY', 'burger', 'Spiders',110 my $ace = Foswiki::AccessControlException->new( 'FRY', 'burger', 'Spiders', 101 111 'FlumpNuts', 'Because it was there.' ); 102 112 $this->assert_str_equals( … … 105 115 ); 106 116 117 return; 107 118 } 108 119 109 120 sub test_oopsScript { 110 121 my $this = shift; 111 my $query = new Unit::Request(122 my $query = Unit::Request->new( 112 123 { 113 124 skin => 'none', … … 121 132 } 122 133 ); 123 my $session = new Foswiki( undef, $query );134 $this->createNewFoswikiSession( undef, $query ); 124 135 my ($output) = 125 $this->capture( $UI_FN, $ session, "Flum", "DeDum", $query, 0 );136 $this->capture( $UI_FN, $this->{session}, "Flum", "DeDum", $query, 0 ); 126 137 $this->assert_matches( qr/^phlegm$/m, $output ); 127 138 $this->assert_matches( qr/^<pus>$/m, $output ); … … 132 143 $this->assert_matches( qr/^phlegm$/m, $output ); 133 144 134 $session->finish();145 return; 135 146 } 136 147 -
branches/Release01x01/UnitTestContrib/test/unit/Fn_GROUPINFO.pm
r13729 r13794 1 # tests for the correct expansion of GROUPINFO 2 3 package Fn_GROUPINFO; 1 4 use strict; 2 3 # tests for the correct expansion of GROUPINFO 4 5 package Fn_GROUPINFO; 6 7 use FoswikiFnTestCase; 5 use warnings; 6 7 use FoswikiFnTestCase(); 8 8 our @ISA = qw( FoswikiFnTestCase ); 9 9 10 use Foswiki; 10 use Foswiki(); 11 use Foswiki::Func(); 11 12 use Error qw( :try ); 12 13 13 14 sub new { 15 my ( $class, @args ) = @_; 16 14 17 $Foswiki::cfg{Register}{AllowLoginName} = 1; 15 my $self = shift()->SUPER::new( 'GROUPINFO', @_ ); 16 return $ self;18 19 return $class->SUPER::new( 'GROUPINFO', @args ); 17 20 } 18 21 … … 20 23 my $this = shift; 21 24 $this->SUPER::set_up(@_); 22 my $topicObject = 23 Foswiki::Meta->new( $this->{session}, $this->{users_web}, "GropeGroup", 24 " * Set GROUP = ScumBag,WikiGuest\n" ); 25 $topicObject->save(); 26 $topicObject = 27 Foswiki::Meta->new( $this->{session}, $this->{users_web}, "PopGroup", 28 " * Set GROUP = WikiGuest\n" ); 29 $topicObject->save(); 30 $topicObject = Foswiki::Meta->new( 31 $this->{session}, $this->{users_web}, 32 "NestingGroup", " * Set GROUP = GropeGroup\n" 33 ); 34 $topicObject->save(); 35 $topicObject = 36 Foswiki::Meta->new( $this->{session}, $this->{users_web}, 37 "OnlyAdminCanChangeGroup", 38 " * Set GROUP = WikiGuest\n * Set TOPICCHANGE = AdminGroup\n" ); 39 $topicObject->save(); 40 $topicObject = 41 Foswiki::Meta->new( $this->{session}, $this->{users_web}, 42 "GroupWithHiddenGroup", " * Set GROUP = HiddenGroup,WikiGuest\n" ); 43 $topicObject->save(); 44 $topicObject = 45 Foswiki::Meta->new( $this->{session}, $this->{users_web}, "HiddenGroup", 46 " * Set GROUP = ScumBag\n * Set ALLOWTOPICVIEW = AdminUser\n" ); 47 $topicObject->save(); 48 49 $topicObject = 50 Foswiki::Meta->new( $this->{session}, $this->{users_web}, 51 "HiddenUserGroup", " * Set GROUP = ScumBag,HidemeGood\n" ); 52 $topicObject->save(); 53 54 $topicObject = 55 Foswiki::Meta->load( $this->{session}, $this->{users_web}, "HidemeGood" ); 25 my ($topicObject) = 26 Foswiki::Func::readTopic( $this->{users_web}, "GropeGroup" ); 27 $topicObject->text(" * Set GROUP = ScumBag,WikiGuest\n"); 28 $topicObject->save(); 29 $topicObject->finish(); 30 ($topicObject) = Foswiki::Func::readTopic( $this->{users_web}, "PopGroup" ); 31 $topicObject->text(" * Set GROUP = WikiGuest\n"); 32 $topicObject->save(); 33 $topicObject->finish(); 34 ($topicObject) = 35 Foswiki::Func::readTopic( $this->{users_web}, "NestingGroup" ); 36 $topicObject->text(" * Set GROUP = GropeGroup\n"); 37 $topicObject->save(); 38 $topicObject->finish(); 39 ($topicObject) = 40 Foswiki::Func::readTopic( $this->{users_web}, "OnlyAdminCanChangeGroup" ); 41 $topicObject->text( 42 " * Set GROUP = WikiGuest\n * Set TOPICCHANGE = AdminGroup\n"); 43 $topicObject->save(); 44 $topicObject->finish(); 45 ($topicObject) = 46 Foswiki::Func::readTopic( $this->{users_web}, "GroupWithHiddenGroup" ); 47 $topicObject->text(" * Set GROUP = HiddenGroup,WikiGuest\n"); 48 $topicObject->save(); 49 $topicObject->finish(); 50 ($topicObject) = 51 Foswiki::Func::readTopic( $this->{users_web}, "HiddenGroup" ); 52 $topicObject->text( 53 " * Set GROUP = ScumBag\n * Set ALLOWTOPICVIEW = AdminUser\n"); 54 $topicObject->save(); 55 $topicObject->finish(); 56 ($topicObject) = 57 Foswiki::Func::readTopic( $this->{users_web}, "HiddenUserGroup" ); 58 $topicObject->text(" * Set GROUP = ScumBag,HidemeGood\n"); 59 $topicObject->save(); 60 $topicObject->finish(); 61 ($topicObject) = 62 Foswiki::Func::readTopic( $this->{users_web}, "HidemeGood" ); 56 63 my $topText = $topicObject->text(); 57 64 $topText .= " * Set ALLOWTOPICVIEW = AdminUser\n"; 58 65 $topText = $topicObject->text($topText); 59 66 $topicObject->save(); 60 67 $topicObject->finish(); 68 69 return; 61 70 } 62 71 … … 70 79 $this->assert_matches( qr/\bGroupWithHiddenGroup\b/, $ui ); 71 80 $this->assert_does_not_match( qr/\bHiddenGroup\b/, $ui ); 81 82 return; 72 83 } 73 84 … … 79 90 $this->assert_matches( qr/\b$this->{users_web}.ScumBag\b/, $ui ); 80 91 $this->assert_matches( qr/\b$this->{users_web}.WikiGuest\b/, $ui ); 81 my @u = split( ',', $ui );92 my @u = split( /,/, $ui ); 82 93 $this->assert( 2, scalar(@u) ); 94 95 return; 83 96 } 84 97 … … 95 108 $this->assert_matches( qr/\b$this->{users_web}.ScumBag\b/, $ui ); 96 109 $this->assert_matches( qr/\b$this->{users_web}.WikiGuest\b/, $ui ); 97 my @u = split( ',', $ui );110 my @u = split( /,/, $ui ); 98 111 $this->assert( 2, scalar(@u) ); 112 113 return; 99 114 } 100 115 … … 107 122 $this->assert_matches( qr/\b$this->{users_web}.WikiGuest\b/, $ui ); 108 123 $this->assert_does_not_match( qr/\b$this->{users_web}.HiddenGroup\b/, $ui ); 109 my @u = split( ',', $ui );124 my @u = split( /,/, $ui ); 110 125 $this->assert( 1, scalar(@u) ); 126 127 return; 111 128 } 112 129 … … 127 144 $ui, 'ScumBag revealed' ); 128 145 129 my @u = split( ',', $ui );146 my @u = split( /,/, $ui ); 130 147 $this->assert( 1, scalar(@u) ); 148 149 return; 131 150 } 132 151 … … 141 160 $this->assert_does_not_match( qr/\b$this->{users_web}.HidemeGood\b/, 142 161 $ui, 'HidemeGood revealed' ); 143 my @u = split( ',', $ui );162 my @u = split( /,/, $ui ); 144 163 $this->assert( 1, scalar(@u) ); 164 165 return; 145 166 } 146 167 … … 148 169 my $this = shift; 149 170 150 $this->{session}->finish(); 151 $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 152 $this->{test_topicObject} = Foswiki::Meta->new( 153 $this->{session}, $this->{test_web}, 154 $this->{test_topic}, "BLEEGLE\n" 155 ); 171 $this->createNewFoswikiSession( $Foswiki::cfg{AdminUserLogin} ); 172 $this->{test_topicObject}->finish if $this->{test_topicObject}; 173 ( $this->{test_topicObject} ) = 174 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 175 $this->{test_topicObject}->text("BLEEGLE\n"); 156 176 $this->{test_topicObject}->save(); 157 177 … … 161 181 $this->assert_matches( qr/$this->{users_web}.ScumBag/, $ui ); 162 182 $this->assert_matches( qr/$this->{users_web}.HidemeGood/, $ui ); 163 my @u = split( ',', $ui );183 my @u = split( /,/, $ui ); 164 184 $this->assert( 2, scalar(@u) ); 185 $this->{test_topicObject}->finish(); 186 187 return; 165 188 } 166 189 … … 201 224 ); 202 225 $this->assert_matches( qr/^<\w+>LF$/, $ui ); 226 227 return; 203 228 } 204 229 -
branches/Release01x01/UnitTestContrib/test/unit/Fn_IF.pm
r13729 r13794 2 2 3 3 package Fn_IF; 4 5 4 use strict; 6 7 use FoswikiFnTestCase; 5 use warnings; 6 7 use FoswikiFnTestCase(); 8 8 our @ISA = qw( FoswikiFnTestCase ); 9 9 10 use Foswiki ;10 use Foswiki(); 11 11 use Error qw( :try ); 12 12 use Assert; … … 17 17 18 18 sub new { 19 my $self = shift()->SUPER::new( 'IF', @_ );20 my $dep = new Foswiki::Configure::Dependency(19 my ( $class, @args ) = @_; 20 my $dep = Foswiki::Configure::Dependency->new( 21 21 type => "perl", 22 22 module => "Foswiki", … … 24 24 ); 25 25 ( $post11, my $message ) = $dep->check(); 26 return $self; 26 27 return $class->SUPER::new( 'IF', @args ); 27 28 } 28 29 … … 30 31 my $this = shift; 31 32 $this->simpleTest( test => "'A'='B'", then => 0, else => 1 ); 33 34 return; 32 35 } 33 36 … … 35 38 my $this = shift; 36 39 $this->simpleTest( test => "'A'!='B'", then => 1, else => 0 ); 40 41 return; 37 42 } 38 43 … … 40 45 my $this = shift; 41 46 $this->simpleTest( test => "'A'='A'", then => 1, else => 0 ); 47 48 return; 42 49 } 43 50 … … 45 52 my $this = shift; 46 53 $this->simpleTest( test => "'A'='B'", then => 0, else => 1 ); 54 55 return; 47 56 } 48 57 … … 50 59 my $this = shift; 51 60 $this->simpleTest( test => 'context test', then => 1, else => 0 ); 61 62 return; 52 63 } 53 64 … … 55 66 my $this = shift; 56 67 $this->simpleTest( test => 'context \'test\'', then => 1, else => 0 ); 68 69 return; 57 70 } 58 71 … … 60 73 my $this = shift; 61 74 $this->simpleTest( test => "{Fnargle}='Fleeble'", then => 1, else => 0 ); 75 76 return; 62 77 } 63 78 … … 65 80 my $this = shift; 66 81 $this->simpleTest( test => "{A}{B}='C'", then => 1, else => 0 ); 82 83 return; 67 84 } 68 85 … … 75 92 else => 0 76 93 ); 94 95 return; 77 96 } 78 97 … … 85 104 else => 0 86 105 ); 106 107 return; 87 108 } 88 109 … … 92 113 93 114 # See test_96* for other 'defined' tests 115 116 return; 94 117 } 95 118 … … 141 164 else => 1 142 165 ); 166 167 return; 143 168 } 144 169 … … 146 171 my $this = shift; 147 172 $this->simpleTest( test => '0>1', then => 0, else => 1 ); 173 174 return; 148 175 } 149 176 … … 151 178 my $this = shift; 152 179 $this->simpleTest( test => '1>0', then => 1, else => 0 ); 180 181 return; 153 182 } 154 183 … … 156 185 my $this = shift; 157 186 $this->simpleTest( test => '1<0', then => 0, else => 1 ); 187 188 return; 158 189 } 159 190 … … 161 192 my $this = shift; 162 193 $this->simpleTest( test => '0<1', then => 1, else => 0 ); 194 195 return; 163 196 } 164 197 … … 166 199 my $this = shift; 167 200 $this->simpleTest( test => "0>=\t1", then => 0, else => 1 ); 201 202 return; 168 203 } 169 204 … … 171 206 my $this = shift; 172 207 $this->simpleTest( test => '1>=0', then => 1, else => 0 ); 208 209 return; 173 210 } 174 211 … … 176 213 my $this = shift; 177 214 $this->simpleTest( test => '1>=1', then => 1, else => 0 ); 215 216 return; 178 217 } 179 218 … … 181 220 my $this = shift; 182 221 $this->simpleTest( test => '1<=0', then => 0, else => 1 ); 222 223 return; 183 224 } 184 225 … … 186 227 my $this = shift; 187 228 $this->simpleTest( test => '0<=1', then => 1, else => 0 ); 229 230 return; 188 231 } 189 232 … … 191 234 my $this = shift; 192 235 $this->simpleTest( test => '1<=1', then => 1, else => 0 ); 236 237 return; 193 238 } 194 239 … … 196 241 my $this = shift; 197 242 $this->simpleTest( test => "not 'A'='B'", then => 1, else => 0 ); 243 244 return; 198 245 } 199 246 … … 201 248 my $this = shift; 202 249 $this->simpleTest( test => "not NOT 'A'='B'", then => 0, else => 1 ); 250 251 return; 203 252 } 204 253 … … 206 255 my $this = shift; 207 256 $this->simpleTest( test => "'A'='A' AND 'B'='B'", then => 1, else => 0 ); 257 258 return; 208 259 } 209 260 … … 211 262 my $this = shift; 212 263 $this->simpleTest( test => "'A'='A' and 'B'='B'", then => 1, else => 0 ); 264 265 return; 213 266 } 214 267 … … 216 269 my $this = shift; 217 270 $this->simpleTest( test => "'A'='A' and 'B'='B'", then => 1, else => 0 ); 271 272 return; 218 273 } 219 274 … … 225 280 else => 0 226 281 ); 282 283 return; 227 284 } 228 285 … … 230 287 my $this = shift; 231 288 $this->simpleTest( test => "'A'='B' or 'B'='B'", then => 1, else => 0 ); 289 290 return; 232 291 } 233 292 … … 235 294 my $this = shift; 236 295 $this->simpleTest( test => "'A'='A' or 'B'='A'", then => 1, else => 0 ); 296 297 return; 237 298 } 238 299 … … 240 301 my $this = shift; 241 302 $this->simpleTest( test => "'A'='B' or 'B'='A'", then => 0, else => 1 ); 303 304 return; 242 305 } 243 306 … … 249 312 else => 0 250 313 ); 314 315 return; 251 316 } 252 317 … … 258 323 else => 0 259 324 ); 325 326 return; 260 327 } 261 328 … … 263 330 my $this = shift; 264 331 $this->simpleTest( test => "'A'~'B'", then => 0, else => 1 ); 332 333 return; 265 334 } 266 335 … … 268 337 my $this = shift; 269 338 $this->simpleTest( test => "'ABLABA'~'*B?AB*'", then => 1, else => 0 ); 339 340 return; 270 341 } 271 342 … … 273 344 my $this = shift; 274 345 $this->simpleTest( test => '\"BABBA\"~\"*BB?\"', then => 1, else => 0 ); 346 347 return; 275 348 } 276 349 … … 278 351 my $this = shift; 279 352 $this->simpleTest( test => "lc('FRED')='fred'", then => 1, else => 0 ); 353 354 return; 280 355 } 281 356 … … 283 358 my $this = shift; 284 359 $this->simpleTest( test => "('FRED')=uc 'fred'", then => 1, else => 0 ); 360 361 return; 285 362 } 286 363 … … 293 370 else => 0 294 371 ); 372 373 return; 295 374 } 296 375 … … 302 381 else => 1 303 382 ); 383 384 return; 304 385 } 305 386 … … 307 388 my $this = shift; 308 389 $this->simpleTest( test => "1 = 1 > 0", then => 1, else => 0 ); 390 391 return; 309 392 } 310 393 … … 312 395 my $this = shift; 313 396 $this->simpleTest( test => "1 > 1 = 0", then => 1, else => 0 ); 397 398 return; 314 399 } 315 400 … … 317 402 my $this = shift; 318 403 $this->simpleTest( test => "not 1 = 2", then => 1, else => 0 ); 404 405 return; 319 406 } 320 407 … … 322 409 my $this = shift; 323 410 $this->simpleTest( test => "not not 1 and 1", then => 1, else => 0 ); 411 412 return; 324 413 } 325 414 … … 327 416 my $this = shift; 328 417 $this->simpleTest( test => "0 or not not 1 and 1", then => 1, else => 0 ); 418 419 return; 329 420 } 330 421 … … 339 430 else => 1 340 431 ); 432 433 return; 341 434 } 342 435 … … 352 445 else => 1 353 446 ); 447 448 return; 354 449 } 355 450 … … 361 456 else => 1 362 457 ); 458 459 return; 363 460 } 364 461 … … 373 470 else => 1 374 471 ); 472 473 return; 375 474 } 376 475 … … 386 485 else => 1 387 486 ); 487 488 return; 388 489 } 389 490 … … 397 498 else => 1 398 499 ); 500 501 return; 399 502 } 400 503 … … 411 514 else => 1 412 515 ); 516 517 return; 413 518 } 414 519 … … 422 527 else => 1 423 528 ); 529 530 return; 424 531 } 425 532 … … 433 540 else => 1 434 541 ); 542 543 return; 435 544 } 436 545 … … 447 556 else => 0 448 557 ); 558 559 return; 449 560 } 450 561 … … 458 569 else => 0 459 570 ); 571 572 return; 460 573 } 461 574 … … 470 583 else => 1 471 584 ); 585 586 return; 472 587 } 473 588 … … 479 594 else => 1 480 595 ); 596 597 return; 481 598 } 482 599 … … 488 605 else => 1 489 606 ); 607 608 return; 490 609 } 491 610 … … 497 616 else => 1 498 617 ); 618 619 return; 499 620 } 500 621 … … 506 627 else => 0 507 628 ); 629 630 return; 508 631 } 509 632 … … 515 638 else => 1 516 639 ); 640 641 return; 517 642 } 518 643 … … 525 650 else => 1 526 651 ); 652 653 return; 527 654 } 528 655 … … 535 662 else => 1 536 663 ); 664 665 return; 537 666 } 538 667 … … 544 673 else => 0 545 674 ); 675 676 return; 546 677 } 547 678 … … 553 684 else => 1 554 685 ); 686 687 return; 555 688 } 556 689 … … 563 696 else => 1 564 697 ); 698 699 return; 565 700 } 566 701 … … 573 708 else => 1 574 709 ); 710 711 return; 575 712 } 576 713 … … 582 719 else => 0 583 720 ); 721 722 return; 584 723 } 585 724 … … 591 730 else => 1 592 731 ); 732 733 return; 593 734 } 594 735 … … 601 742 else => 1 602 743 ); 744 745 return; 603 746 } 604 747 … … 611 754 else => 1 612 755 ); 756 757 return; 613 758 } 614 759 … … 620 765 else => 0 621 766 ); 767 768 return; 622 769 } 623 770 … … 631 778 else => 1 632 779 ); 780 781 return; 633 782 } 634 783 … … 642 791 else => 1 643 792 ); 793 794 return; 644 795 } 645 796 … … 654 805 else => 1 655 806 ); 807 808 return; 656 809 } 657 810 … … 665 818 else => 0 666 819 ); 820 821 return; 667 822 } 668 823 … … 676 831 else => 1 677 832 ); 833 834 return; 678 835 } 679 836 … … 687 844 else => 1 688 845 ); 846 847 return; 689 848 } 690 849 … … 699 858 else => 0 700 859 ); 860 861 return; 701 862 } 702 863 … … 710 871 else => 1 711 872 ); 873 874 return; 712 875 } 713 876 … … 721 884 else => 1 722 885 ); 886 887 return; 723 888 } 724 889 … … 732 897 else => 1 733 898 ); 899 900 return; 734 901 } 735 902 … … 744 911 else => 1 745 912 ); 913 914 return; 746 915 } 747 916 … … 753 922 else => 0 754 923 ); 924 925 return; 755 926 } 756 927 … … 762 933 else => 1 763 934 ); 935 936 return; 764 937 } 765 938 … … 773 946 else => 1 774 947 ); 948 949 return; 775 950 } 776 951 … … 785 960 else => 0 786 961 ); 962 963 return; 787 964 } 788 965 … … 794 971 else => 1 795 972 ); 973 974 return; 796 975 } 797 976 … … 803 982 else => 1 804 983 ); 984 985 return; 805 986 } 806 987 … … 814 995 else => 1 815 996 ); 997 998 return; 816 999 } 817 1000 … … 826 1009 else => 1 827 1010 ); 1011 1012 return; 828 1013 } 829 1014 … … 837 1022 else => 0 838 1023 ); 1024 1025 return; 839 1026 } 840 1027 … … 846 1033 else => 1 847 1034 ); 1035 1036 return; 848 1037 } 849 1038 … … 857 1046 else => 1 858 1047 ); 1048 1049 return; 859 1050 } 860 1051 … … 869 1060 else => 0 870 1061 ); 1062 1063 return; 871 1064 } 872 1065 … … 878 1071 else => 1 879 1072 ); 1073 1074 return; 880 1075 } 881 1076 … … 887 1082 else => 1 888 1083 ); 1084 1085 return; 889 1086 } 890 1087 … … 898 1095 else => 1 899 1096 ); 1097 1098 return; 900 1099 } 901 1100 … … 910 1109 else => 1 911 1110 ); 1111 1112 return; 912 1113 } 913 1114 … … 921 1122 else => 0 922 1123 ); 1124 1125 return; 923 1126 } 924 1127 … … 926 1129 my $this = shift; 927 1130 $this->simpleTest( test => "isweb 'System'", then => 1, else => 0 ); 1131 1132 return; 928 1133 } 929 1134 … … 931 1136 my $this = shift; 932 1137 $this->simpleTest( test => "isweb 'Not a web'", then => 0, else => 1 ); 1138 1139 return; 933 1140 } 934 1141 … … 936 1143 my $this = shift; 937 1144 $this->simpleTest( test => "istopic \$'System'", then => 0, else => 1 ); 1145 1146 return; 938 1147 } 939 1148 … … 941 1150 my $this = shift; 942 1151 $this->simpleTest( test => "istopic \$'Not a web'", then => 0, else => 1 ); 1152 1153 return; 943 1154 } 944 1155 … … 950 1161 else => 1 951 1162 ); 1163 1164 return; 952 1165 } 953 1166 … … 959 1172 else => 1 960 1173 ); 1174 1175 return; 961 1176 } 962 1177 … … 968 1183 else => 1 969 1184 ); 1185 1186 return; 970 1187 } 971 1188 … … 977 1194 else => 1 978 1195 ); 1196 1197 return; 979 1198 } 980 1199 … … 982 1201 my $this = shift; 983 1202 $this->simpleTest( test => "isweb \$ 'SYSTEMWEB'", then => 1, else => 0 ); 1203 1204 return; 984 1205 } 985 1206 … … 987 1208 my $this = shift; 988 1209 $this->simpleTest( test => 'defined \'SYSTEMWEB\'', then => 1, else => 0 ); 1210 1211 return; 989 1212 } 990 1213 … … 994 1217 995 1218 # see also test_9 and test_96* 1219 1220 return; 996 1221 } 997 1222 … … 999 1224 my $this = shift; 1000 1225 $this->simpleTest( test => 'defined( SYSTEMWEB )', then => 1, else => 0 ); 1226 1227 return; 1001 1228 } 1002 1229 … … 1004 1231 my $this = shift; 1005 1232 $this->simpleTest( test => "defined( 'SYSTEMWEB' )", then => 1, else => 0 ); 1233 1234 return; 1006 1235 } 1007 1236 … … 1009 1238 my $this = shift; 1010 1239 $this->simpleTest( test => 'defined( UNDEF )', then => 0, else => 1 ); 1240 1241 return; 1011 1242 } 1012 1243 … … 1014 1245 my $this = shift; 1015 1246 $this->simpleTest( test => "defined( 'UNDEF' )", then => 0, else => 1 ); 1247 1248 return; 1016 1249 } 1017 1250 … … 1019 1252 my $this = shift; 1020 1253 $this->simpleTest( test => 'defined \'IF\'', then => 1, else => 0 ); 1254 1255 return; 1021 1256 } 1022 1257 … … 1024 1259 my $this = shift; 1025 1260 $this->simpleTest( test => 'defined IF', then => 1, else => 0 ); 1261 1262 return; 1026 1263 } 1027 1264 … … 1039 1276 #print STDERR "catched error ".shift."\n"; 1040 1277 }; 1278 1279 return; 1041 1280 } 1042 1281 … … 1045 1284 $this->SUPER::set_up(@_); 1046 1285 1047 my $topicObject = Foswiki::Meta->new( 1048 $this->{session}, 1049 $this->{users_web}, 1050 "GropeGroup", 1051 " * Set GROUP = " 1052 . Foswiki::Func::getWikiName( $this->{session}->{user} ) . "\n" 1053 ); 1286 my ($topicObject) = 1287 Foswiki::Func::readTopic( $this->{users_web}, "GropeGroup" ); 1288 $topicObject->text( " * Set GROUP = " 1289 . Foswiki::Func::getWikiName( $this->{session}->{user} ) 1290 . "\n" ); 1054 1291 $topicObject->save(); 1292 $topicObject->finish(); 1055 1293 1056 1294 # Create WebHome topic to trap existance errors related to 1057 1295 # normalizeWebTopicName 1058 $topicObject = Foswiki::Meta->new( 1059 $this->{session}, $this->{test_web}, 1060 "WebHome", "Gormless gimboid\n" 1061 ); 1296 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, "WebHome" ); 1297 $topicObject->text("Gormless gimboid\n"); 1062 1298 $topicObject->save(); 1299 $topicObject->finish(); 1300 1301 return; 1063 1302 } 1064 1303 … … 1090 1329 #print STDERR "$text => $result\n"; 1091 1330 $this->assert_equals( '1', $result, $text . " => " . $result ); 1331 1332 return; 1092 1333 } 1093 1334 … … 1095 1336 my $this = shift; 1096 1337 1097 my $topicObject=1098 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, "DeadHerring",1099 <<'SMELL');1338 my ($topicObject) = 1339 Foswiki::Func::readTopic( $this->{test_web}, "DeadHerring" ); 1340 $topicObject->text( <<'SMELL'); 1100 1341 one %IF{ "defined NAME" then="1" else="0" }% 1101 1342 two %IF{ "$ NAME='%NAME%'" then="1" else="0" }% … … 1103 1344 SMELL 1104 1345 $topicObject->save(); 1346 $topicObject->finish(); 1105 1347 my $text = <<'PONG'; 1106 1348 %INCLUDE{"DeadHerring" NAME="Red" warn="on"}% … … 1108 1350 my $result = $this->{test_topicObject}->expandMacros($text); 1109 1351 $this->assert_matches( qr/^\s*one 1\s+two 1\s+three 1\s*$/s, $result ); 1352 1353 return; 1110 1354 } 1111 1355 … … 1130 1374 $this->assert_str_equals( $test->{expect}, $result ); 1131 1375 } 1376 1377 return; 1132 1378 } 1133 1379 … … 1135 1381 my $this = shift; 1136 1382 1137 my $topicObject=1138 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, "DeadHerring",1139 <<'SMELL');1383 my ($topicObject) = 1384 Foswiki::Func::readTopic( $this->{test_web}, "DeadHerring" ); 1385 $topicObject->text( <<'SMELL'); 1140 1386 one %IF{ "BleaghForm.Wibble='Woo'" then="1" else="0" }% 1141 1387 %META:FORM{name="BleaghForm"}% … … 1143 1389 SMELL 1144 1390 $topicObject->save(); 1391 $topicObject->finish(); 1145 1392 my $text = <<'PONG'; 1146 1393 %INCLUDE{"DeadHerring" NAME="Red" warn="on"}% … … 1148 1395 my $result = $this->{test_topicObject}->expandMacros($text); 1149 1396 $this->assert_matches( qr/^\s*one 1\s*$/s, $result ); 1397 1398 return; 1150 1399 } 1151 1400 … … 1153 1402 my $this = shift; 1154 1403 my $wn = Foswiki::Func::getWikiName( $this->{session}->{user} ); 1155 my $meta = 1156 Foswiki::Meta->new( $this->{session}, $this->{test_web}, "DeadDog", 1157 <<PONG); 1404 my ($meta) = Foswiki::Func::readTopic( $this->{test_web}, "DeadDog" ); 1405 $meta->text( <<"PONG"); 1158 1406 * Set ALLOWTOPICVIEW = WibbleFloon 1159 1407 * Set ALLOWTOPICCHANGE = $wn 1160 1408 PONG 1161 1409 $meta->save(); 1410 $meta->finish(); 1162 1411 1163 1412 my @tests; … … 1297 1546 } 1298 1547 ); 1299 $this->{session}->finish(); 1300 my $request = new Unit::Request( {} ); 1548 my $request = Unit::Request->new( {} ); 1301 1549 $request->path_info("/$this->{test_web}/$this->{test_topic}"); 1302 $this->{session} = new Foswiki( undef, $request ); 1303 $meta = 1304 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 1305 $this->{test_topic} ); 1550 $this->createNewFoswikiSession( undef, $request ); 1551 ($meta) = 1552 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 1306 1553 1307 1554 foreach my $test (@tests) { … … 1311 1558 "$text: '$result'" ); 1312 1559 } 1560 $meta->finish(); 1561 1562 return; 1313 1563 } 1314 1564 … … 1318 1568 * Set LOOP = %IF{"$ LOOP = '1'" then="ping" else="pong"}% 1319 1569 PONG 1320 my $topicObject=1321 Foswiki:: Meta->new( $this->{session}, $this->{test_web},1322 $this->{test_topic}, $text);1570 my ($topicObject) = 1571 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 1572 $topicObject->text($text); 1323 1573 $topicObject->save(); 1574 $topicObject->finish(); 1324 1575 my $result = $this->{test_topicObject}->expandMacros($text); 1325 1576 $this->assert_str_equals( " * Set LOOP = pong\n", $result ); 1577 1578 return; 1326 1579 } 1327 1580 … … 1331 1584 my $topicName = 'TopicInfo'; 1332 1585 1333 my $meta = 1334 Foswiki::Meta->new( $this->{session}, $this->{test_web}, $topicName, 1335 <<PONG); 1586 my ($meta) = Foswiki::Func::readTopic( $this->{test_web}, $topicName ); 1587 $meta->text( <<'PONG'); 1336 1588 oneapeny twoapenny we all fall down 1337 1589 PONG 1338 1590 $meta->save(); 1339 1340 $meta = 1341 Foswiki::Meta->load( $this->{session},$this->{test_web}, $topicName );1591 $meta->finish(); 1592 1593 ($meta) = Foswiki::Func::readTopic( $this->{test_web}, $topicName ); 1342 1594 $meta->getRevisionInfo(); 1343 1595 my $ti = $meta->get('TOPICINFO'); … … 1408 1660 "$text: '$result'" ); 1409 1661 } 1662 $meta->finish(); 1663 1664
