- Timestamp:
- 01/27/12 04:43:16 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x01/UnitTestContrib/test/unit/Fn_SEARCH.pm
r13729 r13835 1 1 # tests for the correct expansion of SEARCH 2 2 # SMELL: this test is pathetic, becase SEARCH has dozens of untested modes 3 3 # 4 # In order to keep this test down to a manageable run time, the fixture 5 # groups are only applied to those tests where we are testing the correct 6 # parsing of the search expression and its correct application in searching. 7 # Where we are primarily testing formatting and pagination, we keep the 8 # test out of the fixture groups on the assumption that all search and 9 # query algorithms output is formatted by the same code. 10 # 11 # NOTE: When developing, or after modifying search or query algorithms, 12 # you are highly recommended to run this suite with the "test" functions 13 # converted to "verify" - just in case! 14 # 4 15 package Fn_SEARCH; 5 16 … … 7 18 use warnings; 8 19 9 use FoswikiFnTestCase ;20 use FoswikiFnTestCase(); 10 21 our @ISA = qw( FoswikiFnTestCase ); 11 22 12 use Foswiki ;23 use Foswiki(); 13 24 use Error qw( :try ); 14 25 use Assert; 15 use Foswiki::Search;16 use Foswiki::Search ::InfoCache;17 use Foswiki:: Render;26 use English qw( -no_match_vars ); 27 use Foswiki::Search(); 28 use Foswiki::Search::InfoCache(); 18 29 19 30 use File::Spec qw(case_tolerant) … … 21 32 22 33 sub new { 23 my $self = shift()->SUPER::new( 'SEARCH', @_ ); 34 my ( $class, @args ) = @_; 35 my $self = $class->SUPER::new( 'SEARCH', @args ); 36 24 37 return $self; 25 38 } … … 34 47 35 48 sub set_up { 36 my $this = shift; 37 38 $this->SUPER::set_up(); 39 40 my $topicObject = 41 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'OkTopic', 42 "BLEEGLE blah/matchme.blah" ); 43 $topicObject->save(); 44 $topicObject = 45 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'OkATopic', 46 "BLEEGLE dontmatchme.blah" ); 47 $topicObject->save(); 48 $topicObject = 49 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'OkBTopic', 50 "BLEEGLE dont.matchmeblah" ); 51 $topicObject->save(); 49 my ($this) = shift; 50 $this->SUPER::set_up(@_); 51 52 my $timestamp = time(); 53 54 my ($topicObject) = 55 Foswiki::Func::readTopic( $this->{test_web}, 'OkTopic' ); 56 $topicObject->text("BLEEGLE blah/matchme.blah"); 57 $topicObject->save( forcedate => $timestamp + 120 ); 58 $topicObject->finish(); 59 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'OkATopic' ); 60 $topicObject->text("BLEEGLE dontmatchme.blah"); 61 $topicObject->save( forcedate => $timestamp + 240 ); 62 $topicObject->finish(); 63 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'OkBTopic' ); 64 $topicObject->text("BLEEGLE dont.matchmeblah"); 65 $topicObject->save( forcedate => $timestamp + 480 ); 66 $topicObject->finish(); 67 68 ($topicObject) = 69 Foswiki::Func::readTopic( $this->{test_web}, 'InvisibleTopic' ); 70 $topicObject->text("BLEEGLE dont.matchmeblah"); 71 $topicObject->putKeyed( 'PREFERENCE', 72 { name => 'ALLOWTOPICVIEW', value => 'OnlySuperman' } ); 73 $topicObject->save( forcedate => $timestamp + 480 ); 74 $topicObject->finish(); 75 76 return; 52 77 } 53 78 … … 60 85 next unless $alg =~ /^(.*)\.pm$/; 61 86 $alg = $1; 62 if ( $^O eq 'MSWin32' ) { 63 64 #skip forking search for now, its extremely broken on windows 65 next if ( $alg eq 'Forking' ); 66 } 87 88 # skip forking search for now, its extremely broken 89 # on windows 90 next if ( $^O eq 'MSWin32' && $alg eq 'Forking' ); 67 91 $salgs{$alg} = 1; 68 92 } … … 82 106 my $fn = $alg . 'Search'; 83 107 push( @groups, $fn ); 84 next if ( defined( &$fn) );85 eval <<SUB;108 next if ( defined( &{$fn} ) ); 109 if ( not eval <<"SUB" or $EVAL_ERROR ) { 86 110 sub $fn { 87 require Foswiki::Store::SearchAlgorithms::$alg; 88 \$Foswiki::cfg{Store}{SearchAlgorithm} = 'Foswiki::Store::SearchAlgorithms::$alg'; } 111 require Foswiki::Store::SearchAlgorithms::$alg; 112 \$Foswiki::cfg{Store}{SearchAlgorithm} = 'Foswiki::Store::SearchAlgorithms::$alg'; 113 } 114 1; 89 115 SUB 90 die $@ if $@; 116 die $EVAL_ERROR; 117 } 91 118 } 92 119 foreach my $alg ( keys %qalgs ) { … … 94 121 push( @groups, $fn ); 95 122 next if ( defined(&$fn) ); 96 eval <<SUB;123 if ( not eval <<"SUB" or $EVAL_ERROR ) { 97 124 sub $fn { 98 require Foswiki::Store::QueryAlgorithms::$alg; 99 \$Foswiki::cfg{Store}{QueryAlgorithm} = 'Foswiki::Store::QueryAlgorithms::$alg'; } 125 require Foswiki::Store::QueryAlgorithms::$alg; 126 \$Foswiki::cfg{Store}{QueryAlgorithm} = 'Foswiki::Store::QueryAlgorithms::$alg'; 127 } 128 1; 100 129 SUB 101 die $@ if $@; 130 die $EVAL_ERROR; 131 } 102 132 } 103 133 104 return \@groups;134 return ( \@groups ); 105 135 } 106 136 107 137 sub loadExtraConfig { 138 my ( $this, $context, @args ) = @_; # the Test::Unit::TestCase object 139 140 $this->SUPER::loadExtraConfig( $context, @args ); 141 142 #turn on the MongoDBPlugin so that the saved data goes into mongoDB 143 #This is temoprary until Crawford and I cna find a way to push dependencies into unit tests 144 if ( ( $Foswiki::cfg{Store}{SearchAlgorithm} =~ /MongoDB/ ) 145 or ( $Foswiki::cfg{Store}{QueryAlgorithm} =~ /MongoDB/ ) 146 or ( $context =~ /MongoDB/ ) ) 147 { 148 $Foswiki::cfg{Plugins}{MongoDBPlugin}{Module} = 149 'Foswiki::Plugins::MongoDBPlugin'; 150 $Foswiki::cfg{Plugins}{MongoDBPlugin}{Enabled} = 1; 151 $Foswiki::cfg{Plugins}{MongoDBPlugin}{EnableOnSaveUpdates} = 1; 152 153 #push(@{$Foswiki::cfg{Store}{Listeners}}, 'Foswiki::Plugins::MongoDBPlugin::Listener'); 154 $Foswiki::cfg{Store}{Listeners} 155 {'Foswiki::Plugins::MongoDBPlugin::Listener'} = 1; 156 require Foswiki::Plugins::MongoDBPlugin; 157 Foswiki::Plugins::MongoDBPlugin::getMongoDB() 158 ->remove( $this->{test_web}, 'current', 159 { '_web' => $this->{test_web} } ); 160 } 161 162 return; 163 } 164 165 sub tear_down { 108 166 my $this = shift; # the Test::Unit::TestCase object 109 $this->SUPER::loadExtraConfig(); 167 168 $this->SUPER::tear_down(@_); 169 170 #need to clear the web every test? 171 if ( ( $Foswiki::cfg{Store}{SearchAlgorithm} =~ /MongoDB/ ) 172 or ( $Foswiki::cfg{Store}{QueryAlgorithm} =~ /MongoDB/ ) ) 173 { 174 require Foswiki::Plugins::MongoDBPlugin; 175 Foswiki::Plugins::MongoDBPlugin::getMongoDB() 176 ->remove( $this->{test_web}, 'current', 177 { '_web' => $this->{test_web} } ); 178 } 179 180 return; 110 181 } 111 182 … … 121 192 $this->assert_matches( qr/OkBTopic/, $result ); 122 193 $this->assert_matches( qr/OkATopic/, $result ); 194 195 return; 123 196 } 124 197 … … 131 204 132 205 $this->assert_str_equals( '', $result ); 206 207 return; 133 208 } 134 209 … … 145 220 $this->assert_does_not_match( qr/OkBTopic/, $result ); 146 221 $this->assert_does_not_match( qr/OkATopic/, $result ); 222 223 return; 147 224 } 148 225 … … 160 237 $this->assert_matches( qr/OkBTopic/, $result ); 161 238 $this->assert_matches( qr/OkATopic/, $result ); 239 240 return; 162 241 } 163 242 … … 173 252 $this->assert_matches( qr/OkBTopic/, $result ); 174 253 $this->assert_matches( qr/OkATopic/, $result ); 254 255 return; 175 256 } 176 257 … … 188 269 $this->assert_matches( qr/OkBTopic/, $result ); 189 270 $this->assert_matches( qr/OkATopic/, $result ); 271 272 return; 190 273 } 191 274 … … 203 286 $this->assert_matches( qr/OkBTopic/, $result ); 204 287 $this->assert_matches( qr/OkATopic/, $result ); 288 289 return; 205 290 } 206 291 … … 220 305 # 'blah' is in OkATopic, but not as a word 221 306 $this->assert_does_not_match( qr/OkBTopic/, $result, $result ); 307 308 return; 222 309 } 223 310 … … 225 312 my $this = shift; 226 313 227 my $topicObject=228 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'VirtualBeer',229 "There are alot of Virtual Beers to go around");314 my ($topicObject) = 315 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualBeer' ); 316 $topicObject->text("There are alot of Virtual Beers to go around"); 230 317 $topicObject->save(); 231 $topicObject =232 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'RealBeer',233 "There are alot of Virtual Beer to go around");318 $topicObject->finish(); 319 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'RealBeer' ); 320 $topicObject->text("There are alot of Virtual Beer to go around"); 234 321 $topicObject->save(); 235 $topicObject = 236 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'FamouslyBeered', 237 "Virtually speaking there could be alot of famous Beers" ); 322 $topicObject->finish(); 323 ($topicObject) = 324 Foswiki::Func::readTopic( $this->{test_web}, 'FamouslyBeered' ); 325 $topicObject->text( 326 "Virtually speaking there could be alot of famous Beers"); 238 327 $topicObject->save(); 239 $topicObject = 240 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'VirtualLife', 241 "In a all life, I would expect to find fine Beer" ); 328 $topicObject->finish(); 329 ($topicObject) = 330 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualLife' ); 331 $topicObject->text("In a all life, I would expect to find fine Beer"); 242 332 $topicObject->save(); 333 $topicObject->finish(); 243 334 244 335 my $result = … … 247 338 ); 248 339 249 my $expected = << EXPECT;340 my $expected = <<'EXPECT'; 250 341 RealBeer 251 342 VirtualBeer … … 253 344 EXPECT 254 345 $this->assert_str_equals( $expected, $result . "\n" ); 346 347 return; 255 348 } 256 349 … … 258 351 my $this = shift; 259 352 260 my $topicObject=261 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'VirtualBeer',262 "There are alot of Virtual Beers to go around");353 my ($topicObject) = 354 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualBeer' ); 355 $topicObject->text("There are alot of Virtual Beers to go around"); 263 356 $topicObject->save(); 264 $topicObject =265 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'RealBeer',266 "There are alot of Virtual Beer to go around");357 $topicObject->finish(); 358 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'RealBeer' ); 359 $topicObject->text("There are alot of Virtual Beer to go around"); 267 360 $topicObject->save(); 268 $topicObject = 269 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'FamouslyBeered', 270 "Virtually speaking there could be alot of famous Beers" ); 361 $topicObject->finish(); 362 ($topicObject) = 363 Foswiki::Func::readTopic( $this->{test_web}, 'FamouslyBeered' ); 364 $topicObject->text( 365 "Virtually speaking there could be alot of famous Beers"); 271 366 $topicObject->save(); 272 $topicObject = 273 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'VirtualLife', 274 "In a all life, I would expect to find fine Beer" ); 367 $topicObject->finish(); 368 ($topicObject) = 369 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualLife' ); 370 $topicObject->text("In a all life, I would expect to find fine Beer"); 275 371 $topicObject->save(); 372 $topicObject->finish(); 276 373 277 374 my $result = … … 280 377 ); 281 378 282 my $expected = << EXPECT;379 my $expected = <<'EXPECT'; 283 380 FamouslyBeered 284 381 RealBeer … … 287 384 EXPECT 288 385 $this->assert_str_equals( $expected, $result . "\n" ); 386 387 return; 289 388 } 290 389 … … 292 391 my $this = shift; 293 392 294 my $topicObject=295 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'VirtualBeer',296 "There are alot of Virtual Beers to go around");393 my ($topicObject) = 394 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualBeer' ); 395 $topicObject->text("There are alot of Virtual Beers to go around"); 297 396 $topicObject->save(); 298 $topicObject =299 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'RealBeer',300 "There are alot of Virtual Beer to go around");397 $topicObject->finish(); 398 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'RealBeer' ); 399 $topicObject->text("There are alot of Virtual Beer to go around"); 301 400 $topicObject->save(); 302 $topicObject = 303 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'FamouslyBeered', 304 "Virtually speaking there could be alot of famous Beers" ); 401 $topicObject->finish(); 402 ($topicObject) = 403 Foswiki::Func::readTopic( $this->{test_web}, 'FamouslyBeered' ); 404 $topicObject->text( 405 "Virtually speaking there could be alot of famous Beers"); 305 406 $topicObject->save(); 306 $topicObject = 307 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'VirtualLife', 308 "In a all life, I would expect to find fine Beer" ); 407 $topicObject->finish(); 408 ($topicObject) = 409 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualLife' ); 410 $topicObject->text("In a all life, I would expect to find fine Beer"); 309 411 $topicObject->save(); 412 $topicObject->finish(); 310 413 311 414 my $result = … … 314 417 ); 315 418 316 my $expected = << EXPECT;419 my $expected = <<'EXPECT'; 317 420 RealBeer 318 421 VirtualBeer 319 422 EXPECT 320 423 $this->assert_str_equals( $expected, $result . "\n" ); 321 } 424 425 return; 426 } 427 428 sub _expect_with_deps { 429 my ( $this, $default, %expectations ) = @_; 430 my @deps = sort( keys %expectations ); 431 my $expected; 432 my $checking = 1; 433 434 while ( $checking && scalar(@deps) ) { 435 my $dep = shift(@deps); 436 437 if ( $this->check_dependency($dep) ) { 438 $expected = $expectations{$dep}; 439 $checking = 0; 440 } 441 } 442 if ($checking) { 443 $expected = $default; 444 } 445 446 return $expected; 447 } 448 449 # Verify that the default result orering is independent of the web= and 450 # topic= parameters 451 sub verify_default_alpha_order_query { 452 my $this = shift; 453 my $result = $this->{test_topicObject}->expandMacros( 454 '%SEARCH{ 455 "1" 456 type="query" 457 web="System,Main,Sandbox" 458 topic="WebSearch,WebHome,WebPreferences" 459 nonoise="on" 460 format="$web.$topic" 461 }%' 462 ); 463 my $expected = $this->_expect_with_deps( 464 <<'FOSWIKI12', 465 Main.WebHome 466 Main.WebPreferences 467 Main.WebSearch 468 Sandbox.WebHome 469 Sandbox.WebPreferences 470 Sandbox.WebSearch 471 System.WebHome 472 System.WebPreferences 473 System.WebSearch 474 FOSWIKI12 475 'Foswiki,<,1.2' => <<'FOSWIKI11'); 476 System.WebHome 477 System.WebPreferences 478 System.WebSearch 479 Main.WebHome 480 Main.WebPreferences 481 Main.WebSearch 482 Sandbox.WebHome 483 Sandbox.WebPreferences 484 Sandbox.WebSearch 485 FOSWIKI11 486 $expected =~ s/\n$//s; 487 $this->assert_str_equals( $expected, $result ); 488 489 return; 490 } 491 492 sub verify_default_alpha_order_search { 493 my $this = shift; 494 my $result = $this->{test_topicObject}->expandMacros( 495 '%SEARCH{ 496 "." 497 type="regex" 498 web="System,Main,Sandbox" 499 topic="WebSearch,WebHome,WebPreferences" 500 nonoise="on" 501 format="$web.$topic" 502 }%' 503 ); 504 my $expected = $this->_expect_with_deps( 505 <<'FOSWIKI12', 506 Main.WebHome 507 Main.WebPreferences 508 Main.WebSearch 509 Sandbox.WebHome 510 Sandbox.WebPreferences 511 Sandbox.WebSearch 512 System.WebHome 513 System.WebPreferences 514 System.WebSearch 515 FOSWIKI12 516 'Foswiki,<,1.2' => <<'FOSWIKI11'); 517 System.WebHome 518 System.WebPreferences 519 System.WebSearch 520 Main.WebHome 521 Main.WebPreferences 522 Main.WebSearch 523 Sandbox.WebHome 524 Sandbox.WebPreferences 525 Sandbox.WebSearch 526 FOSWIKI11 527 $expected =~ s/\n$//s; 528 $this->assert_str_equals( $expected, $result ); 529 530 return; 531 } 532 322 533 ##################### 323 534 sub _septic { … … 333 544 $expected =~ s/\n$//s; 334 545 $this->assert_str_equals( $expected, $result ); 546 547 return; 335 548 } 336 549 337 550 ##################### 338 551 339 sub verify_no_header_no_footer_no_separator_with_results {340 my $this = shift; 341 $this->_septic( 0, 0, undef, 1, << EXPECT);552 sub test_no_header_no_footer_no_separator_with_results { 553 my $this = shift; 554 $this->_septic( 0, 0, undef, 1, <<'EXPECT'); 342 555 OkATopic 343 556 OkBTopic 344 557 OkTopic 345 558 EXPECT 346 } 347 348 sub verify_no_header_no_footer_no_separator_no_results { 349 my $this = shift; 350 $this->_septic( 0, 0, undef, 0, <<EXPECT); 559 560 return; 561 } 562 563 sub test_no_header_no_footer_no_separator_no_results { 564 my $this = shift; 565 $this->_septic( 0, 0, undef, 0, <<'EXPECT'); 351 566 EXPECT 352 } 353 354 sub verify_no_header_no_footer_empty_separator_with_results { 355 my $this = shift; 356 $this->_septic( 0, 0, "", 1, <<EXPECT); 567 568 return; 569 } 570 571 sub test_no_header_no_footer_empty_separator_with_results { 572 my $this = shift; 573 $this->_septic( 0, 0, "", 1, <<'EXPECT'); 357 574 OkATopicOkBTopicOkTopic 358 575 EXPECT 359 } 360 361 sub verify_no_header_no_footer_empty_separator_no_results { 362 my $this = shift; 363 $this->_septic( 0, 0, "", 0, <<EXPECT); 576 577 return; 578 } 579 580 sub test_no_header_no_footer_empty_separator_no_results { 581 my $this = shift; 582 $this->_septic( 0, 0, "", 0, <<'EXPECT'); 364 583 EXPECT 365 } 366 367 sub verify_no_header_no_footer_with_separator_with_results { 368 my $this = shift; 369 $this->_septic( 0, 0, ",", 1, <<EXPECT); 584 585 return; 586 } 587 588 sub test_no_header_no_footer_with_separator_with_results { 589 my $this = shift; 590 $this->_septic( 0, 0, ",", 1, <<'EXPECT'); 370 591 OkATopic,OkBTopic,OkTopic 371 592 EXPECT 372 } 373 374 sub verify_no_header_no_footer_with_nl_separator_with_results { 375 my $this = shift; 376 $this->_septic( 0, 0, '$n', 1, <<EXPECT); 593 594 return; 595 } 596 597 sub test_no_header_no_footer_with_nl_separator_with_results { 598 my $this = shift; 599 $this->_septic( 0, 0, '$n', 1, <<'EXPECT'); 377 600 OkATopic 378 601 OkBTopic 379 602 OkTopic 380 603 EXPECT 381 } 382 383 sub verify_no_header_no_footer_with_separator_no_results { 384 my $this = shift; 385 $this->_septic( 0, 0, ",", 0, <<EXPECT); 604 605 return; 606 } 607 608 sub test_no_header_no_footer_with_separator_no_results { 609 my $this = shift; 610 $this->_septic( 0, 0, ",", 0, <<'EXPECT'); 386 611 EXPECT 612 613 return; 387 614 } 388 615 ##################### 389 616 390 sub verify_no_header_with_footer_no_separator_with_results {391 my $this = shift; 392 $this->_septic( 0, 1, undef, 1, << EXPECT);617 sub test_no_header_with_footer_no_separator_with_results { 618 my $this = shift; 619 $this->_septic( 0, 1, undef, 1, <<'EXPECT'); 393 620 OkATopic 394 621 OkBTopic … … 396 623 FOOT 397 624 EXPECT 398 } 399 400 sub verify_no_header_with_footer_no_separator_no_results { 401 my $this = shift; 402 $this->_septic( 0, 1, undef, 0, <<EXPECT); 625 626 return; 627 } 628 629 sub test_no_header_with_footer_no_separator_no_results { 630 my $this = shift; 631 $this->_septic( 0, 1, undef, 0, <<'EXPECT'); 403 632 EXPECT 404 } 405 406 sub verify_no_header_with_footer_empty_separator_with_results { 407 my $this = shift; 408 $this->_septic( 0, 1, "", 1, <<EXPECT); 633 634 return; 635 } 636 637 sub test_no_header_with_footer_empty_separator_with_results { 638 my $this = shift; 639 $this->_septic( 0, 1, "", 1, <<'EXPECT'); 409 640 OkATopicOkBTopicOkTopicFOOT 410 641 EXPECT 411 } 412 413 sub verify_no_header_with_footer_empty_separator_no_results { 414 my $this = shift; 415 $this->_septic( 0, 1, "", 0, <<EXPECT); 642 643 return; 644 } 645 646 sub test_no_header_with_footer_empty_separator_no_results { 647 my $this = shift; 648 $this->_septic( 0, 1, "", 0, <<'EXPECT'); 416 649 EXPECT 417 } 418 419 sub verify_no_header_with_footer_with_separator_with_results { 420 my $this = shift; 421 $this->_septic( 0, 1, ",", 1, <<EXPECT); 650 651 return; 652 } 653 654 sub test_no_header_with_footer_with_separator_with_results { 655 my $this = shift; 656 $this->_septic( 0, 1, ",", 1, <<'EXPECT'); 422 657 OkATopic,OkBTopic,OkTopicFOOT 423 658 EXPECT 659 660 return; 424 661 } 425 662 426 663 ##################### 427 664 428 sub verify_with_header_with_footer_no_separator_with_results {429 my $this = shift; 430 $this->_septic( 1, 1, undef, 1, << EXPECT);665 sub test_with_header_with_footer_no_separator_with_results { 666 my $this = shift; 667 $this->_septic( 1, 1, undef, 1, <<'EXPECT'); 431 668 HEAD 432 669 OkATopic … … 435 672 FOOT 436 673 EXPECT 437 } 438 439 sub verify_with_header_with_footer_no_separator_no_results { 440 my $this = shift; 441 $this->_septic( 1, 1, undef, 0, <<EXPECT); 674 675 return; 676 } 677 678 sub test_with_header_with_footer_no_separator_no_results { 679 my $this = shift; 680 $this->_septic( 1, 1, undef, 0, <<'EXPECT'); 442 681 EXPECT 443 } 444 445 sub verify_with_header_with_footer_empty_separator_with_results { 446 my $this = shift; 447 $this->_septic( 1, 1, "", 1, <<EXPECT); 682 683 return; 684 } 685 686 sub test_with_header_with_footer_empty_separator_with_results { 687 my $this = shift; 688 $this->_septic( 1, 1, "", 1, <<'EXPECT'); 448 689 HEADOkATopicOkBTopicOkTopicFOOT 449 690 EXPECT 450 } 451 452 sub verify_with_header_with_footer_empty_separator_no_results { 453 my $this = shift; 454 $this->_septic( 1, 1, "", 0, <<EXPECT); 691 692 return; 693 } 694 695 sub test_with_header_with_footer_empty_separator_no_results { 696 my $this = shift; 697 $this->_septic( 1, 1, "", 0, <<'EXPECT'); 455 698 EXPECT 456 } 457 458 sub verify_with_header_with_footer_with_separator_with_results { 459 my $this = shift; 460 $this->_septic( 1, 1, ",", 1, <<EXPECT); 699 700 return; 701 } 702 703 sub test_with_header_with_footer_with_separator_with_results { 704 my $this = shift; 705 $this->_septic( 1, 1, ",", 1, <<'EXPECT'); 461 706 HEADOkATopic,OkBTopic,OkTopicFOOT 462 707 EXPECT 463 } 464 465 sub verify_with_header_with_footer_with_separator_no_results { 466 my $this = shift; 467 $this->_septic( 1, 1, ",", 0, <<EXPECT); 708 709 return; 710 } 711 712 sub test_with_header_with_footer_with_separator_no_results { 713 my $this = shift; 714 $this->_septic( 1, 1, ",", 0, <<'EXPECT'); 468 715 EXPECT 716 717 return; 469 718 } 470 719 471 720 ##################### 472 721 473 sub verify_with_header_no_footer_no_separator_with_results {474 my $this = shift; 475 $this->_septic( 1, 0, undef, 1, << EXPECT);722 sub test_with_header_no_footer_no_separator_with_results { 723 my $this = shift; 724 $this->_septic( 1, 0, undef, 1, <<'EXPECT'); 476 725 HEAD 477 726 OkATopic … … 479 728 OkTopic 480 729 EXPECT 481 } 482 483 sub verify_with_header_no_footer_no_separator_no_results { 484 my $this = shift; 485 $this->_septic( 1, 0, undef, 0, <<EXPECT); 730 731 return; 732 } 733 734 sub test_with_header_no_footer_no_separator_no_results { 735 my $this = shift; 736 $this->_septic( 1, 0, undef, 0, <<'EXPECT'); 486 737 EXPECT 487 } 488 489 sub verify_with_header_no_footer_empty_separator_with_results { 490 my $this = shift; 491 $this->_septic( 1, 0, "", 1, <<EXPECT); 738 739 return; 740 } 741 742 sub test_with_header_no_footer_empty_separator_with_results { 743 my $this = shift; 744 $this->_septic( 1, 0, "", 1, <<'EXPECT'); 492 745 HEADOkATopicOkBTopicOkTopic 493 746 EXPECT 494 } 495 496 sub verify_with_header_no_footer_empty_separator_no_results { 497 my $this = shift; 498 $this->_septic( 1, 0, "", 0, <<EXPECT); 747 748 return; 749 } 750 751 sub test_with_header_no_footer_empty_separator_no_results { 752 my $this = shift; 753 $this->_septic( 1, 0, "", 0, <<'EXPECT'); 499 754 EXPECT 500 } 501 502 sub verify_with_header_no_footer_with_separator_with_results { 503 my $this = shift; 504 $this->_septic( 1, 0, ",", 1, <<EXPECT); 755 756 return; 757 } 758 759 sub test_with_header_no_footer_with_separator_with_results { 760 my $this = shift; 761 $this->_septic( 1, 0, ",", 1, <<'EXPECT'); 505 762 HEADOkATopic,OkBTopic,OkTopic 506 763 EXPECT 507 } 508 509 sub verify_with_header_no_footer_with_separator_no_results { 510 my $this = shift; 511 $this->_septic( 1, 0, ",", 0, <<EXPECT); 764 765 return; 766 } 767 768 sub test_with_header_no_footer_with_separator_no_results { 769 my $this = shift; 770 $this->_septic( 1, 0, ",", 0, <<'EXPECT'); 512 771 EXPECT 513 } 514 515 sub verify_no_header_no_footer_with_nl_separator { 516 my $this = shift; 517 $this->_septic( 0, 0, '$n', 1, <<EXPECT); 772 773 return; 774 } 775 776 sub test_no_header_no_footer_with_nl_separator { 777 my $this = shift; 778 $this->_septic( 0, 0, '$n', 1, <<'EXPECT'); 518 779 OkATopic 519 780 OkBTopic 520 781 OkTopic 521 782 EXPECT 522 } 523 524 ##################### 525 526 sub verify_footer_with_ntopics { 527 my $this = shift; 528 529 my $result = 530 $this->{test_topicObject}->expandMacros( 531 '%SEARCH{"name~\'*Topic\'" type="query" nonoise="on" footer="Total found: $ntopics" format="$topic"}%' 532 ); 533 534 $this->assert_str_equals( 535 join( "\n", sort qw(OkATopic OkBTopic OkTopic) ) . "\nTotal found: 3", 536 $result ); 537 } 538 539 sub verify_multiple_and_footer_with_ntopics_and_nhits { 540 my $this = shift; 541 542 $this->set_up_for_formatted_search(); 543 544 my $result = 545 $this->{test_topicObject}->expandMacros( 546 '%SEARCH{"Bullet" type="regex" multiple="on" nonoise="on" footer="Total found: $ntopics, Hits: $nhits" format="$text - $nhits"}%' 547 ); 548 549 $this->assert_str_equals( 550 " * Bullet 1 - 1\n * Bullet 2 - 2\n * Bullet 3 - 3\n * Bullet 4 - 4\nTotal found: 1, Hits: 4", 551 $result 552 ); 553 } 554 555 sub verify_footer_with_ntopics_empty_format { 556 my $this = shift; 557 558 my $result = 559 $this->{test_topicObject}->expandMacros( 560 '%SEARCH{"name~\'*Topic\'" type="query" nonoise="on" footer="Total found: $ntopics" format="" separator=""}%' 561 ); 562 563 $this->assert_str_equals( "Total found: 3", $result ); 564 } 565 566 sub verify_nofinalnewline { 567 my $this = shift; 568 569 # nofinalnewline="off" 570 my $result = 571 $this->{test_topicObject}->expandMacros( 572 '%SEARCH{"name~\'OkTopic\'" type="query" nonoise="on" format="$topic" nofinalnewline="off"}%' 573 ); 574 575 $this->assert_str_equals( "OkTopic\n", $result ); 576 577 # nofinalnewline="on" 578 $result = 579 $this->{test_topicObject}->expandMacros( 580 '%SEARCH{"name~\'OkTopic\'" type="query" nonoise="on" format="$topic" nofinalnewline="on"}%' 581 ); 582 583 $this->assert_str_equals( "OkTopic", $result ); 584 585 # nofinalnewline should default be on 586 $result = 587 $this->{test_topicObject}->expandMacros( 588 '%SEARCH{"name~\'OkTopic\'" type="query" nonoise="on" format="$topic"}%' 589 ); 590 591 $this->assert_str_equals( "OkTopic", $result ); 592 783 784 return; 593 785 } 594 786 … … 604 796 $this->assert_matches( qr/OkBTopic/, $result ); 605 797 $this->assert_matches( qr/OkATopic/, $result ); 798 799 return; 606 800 } 607 801 … … 619 813 $this->assert_matches( qr/OkBTopic/, $result ); 620 814 $this->assert_matches( qr/OkATopic/, $result ); 815 816 return; 621 817 } 622 818 … … 634 830 $this->assert_matches( qr/OkBTopic/, $result ); 635 831 $this->assert_matches( qr/OkATopic/, $result ); 832 833 return; 636 834 } 637 835 … … 649 847 $this->assert_does_not_match( qr/OkBTopic/, $result ); 650 848 $this->assert_does_not_match( qr/OkATopic/, $result ); 849 850 return; 651 851 } 652 852 … … 666 866 $this->assert_matches( qr/OkBTopic/, $result ); 667 867 $this->assert_matches( qr/OkATopic/, $result ); 868 869 return; 668 870 } 669 871 … … 681 883 $this->assert_matches( qr/OkBTopic/, $result ); 682 884 $this->assert_matches( qr/OkATopic/, $result ); 885 886 return; 683 887 } 684 888 … … 697 901 $this->assert_matches( qr/OkATopic/, $result ); 698 902 903 return; 699 904 } 700 905 … … 713 918 $this->assert_does_not_match( qr/OkATopic/, $result ); 714 919 920 return; 715 921 } 716 922 … … 730 936 $this->assert_does_not_match( qr/OkBTopic/, $result ); 731 937 $this->assert_does_not_match( qr/OkATopic/, $result ); 938 939 return; 732 940 } 733 941 … … 746 954 $this->assert_does_not_match( qr/OkATopic/, $result ); 747 955 956 return; 748 957 } 749 958 … … 762 971 $this->assert_does_not_match( qr/OkATopic/, $result ); 763 972 973 return; 764 974 } 765 975 … … 778 988 $this->assert_does_not_match( qr/OkATopic/, $result ); 779 989 990 return; 780 991 } 781 992 … … 796 1007 $this->assert_does_not_match( qr/OkATopic/, $result ); 797 1008 1009 return; 798 1010 } 799 1011 … … 812 1024 $this->assert_does_not_match( qr/OkATopic/, $result ); 813 1025 1026 return; 814 1027 } 815 1028 … … 828 1041 $this->assert_does_not_match( qr/OkATopic/, $result ); 829 1042 1043 return; 830 1044 } 831 1045 … … 844 1058 $this->assert_does_not_match( qr/OkATopic/, $result ); 845 1059 1060 return; 846 1061 } 847 1062 … … 862 1077 $this->assert_does_not_match( qr/OkBTopic/, $result ); 863 1078 1079 return; 864 1080 } 865 1081 … … 878 1094 $this->assert_does_not_match( qr/OkBTopic/, $result ); 879 1095 1096 return; 880 1097 } 881 1098 … … 894 1111 $this->assert_matches( qr/OkATopic/, $result ); 895 1112 1113 return; 896 1114 } 897 1115 … … 907 1125 $this->assert_does_not_match( qr/OkATopic/, $result ); 908 1126 $this->assert_matches( qr/OkBTopic/, $result ); 1127 1128 return; 909 1129 } 910 1130 … … 922 1142 HERE 923 1143 $this->assert_str_equals( "$wn $this->{users_web}.$wn\n", $result ); 1144 1145 return; 924 1146 } 925 1147 … … 931 1153 '%SEARCH{"" type="regex" scope="text" nonoise="on" format="$topic"}%'); 932 1154 $this->assert_str_equals( "", $result ); 1155 1156 return; 933 1157 } 934 1158 … … 941 1165 ); 942 1166 $this->assert_str_equals( "", $result ); 1167 1168 return; 943 1169 } 944 1170 … … 951 1177 ); 952 1178 $this->assert_str_equals( "", $result ); 1179 1180 return; 953 1181 } 954 1182 … … 960 1188 '%SEARCH{"" type="word" scope="text" nonoise="on" format="$topic"}%'); 961 1189 $this->assert_str_equals( "", $result ); 1190 1191 return; 962 1192 } 963 1193 … … 970 1200 ); 971 1201 $this->assert_str_equals( "", $result ); 1202 1203 return; 972 1204 } 973 1205 … … 980 1212 ); 981 1213 $this->assert_str_equals( "", $result ); 1214 1215 return; 982 1216 } 983 1217 … … 990 1224 ); 991 1225 $this->assert_str_equals( "", $result ); 1226 1227 return; 992 1228 } 993 1229 … … 1000 1236 ); 1001 1237 $this->assert_str_equals( "", $result ); 1238 1239 return; 1002 1240 } 1003 1241 … … 1021 1259 HERE 1022 1260 1023 my $topicObject=1024 Foswiki:: Meta->new( $this->{session}, $this->{test_web},1025 'FormattedSearchTopic1', $text);1261 my ($topicObject) = 1262 Foswiki::Func::readTopic( $this->{test_web}, 'FormattedSearchTopic1' ); 1263 $topicObject->text($text); 1026 1264 $topicObject->save(); 1027 } 1028 1029 sub verify_formatted_search_summary_with_exclamation_marks { 1265 $topicObject->finish(); 1266 1267 return; 1268 } 1269 1270 sub test_footer_with_ntopics { 1271 my $this = shift; 1272 1273 my $result = 1274 $this->{test_topicObject}->expandMacros( 1275 '%SEARCH{"name~\'*Topic\'" type="query" nonoise="on" footer="Total found: $ntopics" format="$topic"}%' 1276 ); 1277 1278 $this->assert_str_equals( 1279 join( "\n", sort qw(OkATopic OkBTopic OkTopic) ) . "\nTotal found: 3", 1280 $result ); 1281 1282 return; 1283 } 1284 1285 sub test_multiple_and_footer_with_ntopics_and_nhits { 1286 my $this = shift; 1287 1288 $this->set_up_for_formatted_search(); 1289 1290 my $result = 1291 $this->{test_topicObject}->expandMacros( 1292 '%SEARCH{"Bullet" type="regex" multiple="on" nonoise="on" footer="Total found: $ntopics, Hits: $nhits" format="$text - $nhits"}%' 1293 ); 1294 1295 $this->assert_str_equals( 1296 " * Bullet 1 - 1\n * Bullet 2 - 2\n * Bullet 3 - 3\n * Bullet 4 - 4\nTotal found: 1, Hits: 4", 1297 $result 1298 ); 1299 1300 return; 1301 } 1302 1303 sub test_footer_with_ntopics_empty_format { 1304 my $this = shift; 1305 1306 my $result = 1307 $this->{test_topicObject}->expandMacros( 1308 '%SEARCH{"name~\'*Topic\'" type="query" nonoise="on" footer="Total found: $ntopics" format="" separator=""}%' 1309 ); 1310 1311 $this->assert_str_equals( "Total found: 3", $result ); 1312 1313 return; 1314 } 1315 1316 sub test_nofinalnewline { 1317 my $this = shift; 1318 1319 # nofinalnewline="off" 1320 my $result = 1321 $this->{test_topicObject}->expandMacros( 1322 '%SEARCH{"name~\'OkTopic\'" type="query" nonoise="on" format="$topic" nofinalnewline="off"}%' 1323 ); 1324 1325 $this->assert_str_equals( "OkTopic\n", $result ); 1326 1327 # nofinalnewline="on" 1328 $result = 1329 $this->{test_topicObject}->expandMacros( 1330 '%SEARCH{"name~\'OkTopic\'" type="query" nonoise="on" format="$topic" nofinalnewline="on"}%' 1331 ); 1332 1333 $this->assert_str_equals( "OkTopic", $result ); 1334 1335 # nofinalnewline should default be on 1336 $result = 1337 $this->{test_topicObject}->expandMacros( 1338 '%SEARCH{"name~\'OkTopic\'" type="query" nonoise="on" format="$topic"}%' 1339 ); 1340 1341 $this->assert_str_equals( "OkTopic", $result ); 1342 1343 return; 1344 } 1345 1346 sub test_formatted_search_summary_with_exclamation_marks { 1030 1347 my $this = shift; 1031 1348 my $session = $this->{session}; … … 1050 1367 $expected = '<nop>AnnaAnchor'; 1051 1368 $this->assert_str_equals( $expected, $actual ); 1369 1370 return; 1052 1371 } 1053 1372 1054 1373 # Item8718 1055 sub verify_formatted_search_with_exclamation_marks_inside_bracket_link {1374 sub test_formatted_search_with_exclamation_marks_inside_bracket_link { 1056 1375 my $this = shift; 1057 1376 my $session = $this->{session}; … … 1069 1388 1070 1389 $this->assert_str_equals( $expected, $actual ); 1390 1391 return; 1071 1392 } 1072 1393 … … 1085 1406 $result 1086 1407 ); 1408 1409 return; 1087 1410 } 1088 1411 … … 1099 1422 $this->assert_str_equals( "FormattedSearchTopic1 \$email \$html \$time", 1100 1423 $result ); 1101 } 1102 1103 sub verify_METASEARCH { 1424 1425 return; 1426 } 1427 1428 sub test_METASEARCH { 1104 1429 my $this = shift; 1105 1430 my $session = $this->{session}; … … 1124 1449 $this->{test_topicObject}->renderTML('Children: FormattedSearchTopic1 '); 1125 1450 $this->assert_str_equals( $expected, $actual ); 1451 1452 return; 1126 1453 } 1127 1454 … … 1142 1469 %META:FILEATTACHMENT{name="README" comment="Blah Blah" date="1157965062" size="5504"}% 1143 1470 HERE 1144 my $topicObject=1145 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'QueryTopic',1146 $text);1471 my ($topicObject) = 1472 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopic' ); 1473 $topicObject->text($text); 1147 1474 $topicObject->save(); 1475 $topicObject->finish(); 1148 1476 1149 1477 $text = <<'HERE'; … … 1160 1488 %META:FIELD{name="form" attributes="" title="Blah" value="form good"}% 1161 1489 %META:FIELD{name="FORM" attributes="" title="Blah" value="FORM GOOD"}% 1162 %META:FIELD{name="NewField" attributes="" title="Item10269" value=" TaxonProfile/Builder.TermForm"}%1490 %META:FIELD{name="NewField" attributes="" title="Item10269" value="Profile/Builder.TermForm"}% 1163 1491 %META:FILEATTACHMENT{name="porn.gif" comment="Cor" date="15062" size="15504"}% 1164 1492 %META:FILEATTACHMENT{name="flib.xml" comment="Cor" date="1157965062" size="1"}% 1165 1493 HERE 1166 $topicObject=1167 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'QueryTopicTwo',1168 $text);1494 ($topicObject) = 1495 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 1496 $topicObject->text($text); 1169 1497 $topicObject->save(); 1170 1171 $this->{session}->finish(); 1172 my $query = new Unit::Request("");1498 $topicObject->finish(); 1499 1500 my $query = Unit::Request->new(''); 1173 1501 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 1174 1502 1175 $this-> {session} = new Foswiki( undef, $query );1503 $this->createNewFoswikiSession( undef, $query ); 1176 1504 $this->assert_str_equals( $this->{test_web}, $this->{session}->{webName} ); 1177 $Foswiki::Plugins::SESSION = $this->{session}; 1178 1179 $this->{test_topicObject} = 1180 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 1181 $this->{test_topic} ); 1505 1506 return; 1182 1507 } 1183 1508 … … 1195 1520 ->expandMacros( '%SEARCH{"parent.name=\'WebHome\'"' . $stdCrap ); 1196 1521 $this->assert_str_equals( 'QueryTopic', $result ); 1522 1523 return; 1197 1524 } 1198 1525 … … 1206 1533 ->expandMacros( '%SEARCH{"attachments[size > 0]"' . $stdCrap ); 1207 1534 $this->assert_str_equals( 'QueryTopic QueryTopicTwo', $result ); 1535 1536 return; 1208 1537 } 1209 1538 … … 1217 1546 '%SEARCH{"META:FILEATTACHMENT[size > 10000]"' . $stdCrap ); 1218 1547 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1548 1549 return; 1219 1550 } 1220 1551 … … 1228 1559 ->expandMacros( '%SEARCH{"attachments[name=\'flib.xml\']"' . $stdCrap ); 1229 1560 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1561 1562 return; 1230 1563 } 1231 1564 … … 1239 1572 ->expandMacros( '%SEARCH{"Lastname=\'Peel\'"' . $stdCrap ); 1240 1573 $this->assert_str_equals( 'QueryTopic QueryTopicTwo', $result ); 1574 1575 return; 1241 1576 } 1242 1577 … … 1250 1585 '%SEARCH{"text ~ \'*SMONG*\' AND Lastname=\'Peel\'"' . $stdCrap ); 1251 1586 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1587 1588 return; 1252 1589 } 1253 1590 … … 1261 1598 '%SEARCH{"text ~ \'*FURTLE*\' AND Lastname=\'Peel\'"' . $stdCrap ); 1262 1599 $this->assert_str_equals( 'QueryTopic', $result ); 1600 1601 return; 1263 1602 } 1264 1603 … … 1272 1611 ->expandMacros( '%SEARCH{"Lastname=\'Peel\'"' . $stdCrap ); 1273 1612 $this->assert_str_equals( 'QueryTopic QueryTopicTwo', $result ); 1613 1614 return; 1274 1615 } 1275 1616 … … 1283 1624 ->expandMacros( '%SEARCH{"form.name=\'TestyForm\'"' . $stdCrap ); 1284 1625 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1285 } 1286 1626 1627 return; 1628 } 1629 1630 #Item10520: in Sven's reading of System.QuerySearch, this should return no results, as there is no field of the name 'TestForm' 1287 1631 sub verify_formQuery2 { 1288 1632 my $this = shift; … … 1293 1637 $this->{test_topicObject} 1294 1638 ->expandMacros( '%SEARCH{"TestForm"' . $stdCrap ); 1295 $this->assert_str_equals( 'QueryTopic', $result ); 1639 my $expected = 1640 $this->_expect_with_deps( '', 'Foswiki,<,1.2' => 'QueryTopic' ); 1641 1642 $this->assert_str_equals( $expected, $result ); 1643 1644 return; 1296 1645 } 1297 1646 … … 1305 1654 '%SEARCH{"TestForm[name=\'Field1\'].value=\'A Field\'"' . $stdCrap ); 1306 1655 $this->assert_str_equals( 'QueryTopic', $result ); 1656 1657 return; 1307 1658 } 1308 1659 … … 1328 1679 ->expandMacros( '%SEARCH{"TestForm.Field1=\'A Field\'"' . $stdCrap ); 1329 1680 $this->assert_str_equals( 'QueryTopic', $result ); 1681 1682 return; 1330 1683 } 1331 1684 … … 1355 1708 ->expandMacros( '%SEARCH{"TestyForm.FORM=\'FORM GOOD\'"' . $stdCrap ); 1356 1709 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1710 1711 return; 1357 1712 } 1358 1713 … … 1367 1722 . $stdCrap ); 1368 1723 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1724 1725 return; 1369 1726 } 1370 1727 … … 1412 1769 1413 1770 my $result = 1414 $this->{test_topicObject}->expandMacros( '%SEARCH{"A *B"' . $stdCrap );1415 $this->assert_matches( qr/Error was: Syntax error in 'A \* B' at ' \*B'/s,1771 $this->{test_topicObject}->expandMacros( '%SEARCH{"A ¬ B"' . $stdCrap ); 1772 $this->assert_matches( qr/Error was: Syntax error in 'A ¬ B' at ' ¬ B'/s, 1416 1773 $result ); 1774 1775 return; 1417 1776 } 1418 1777 … … 1434 1793 my $vD = ( $n == 1 ) ? 'A' : 'B'; 1435 1794 my $vE = ( $n == 2 ) ? 'A' : 'B'; 1436 my $text = << HERE;1795 my $text = <<"HERE"; 1437 1796 %META:TOPICINFO{author="TopicUserMapping_guest" date="12" format="1.1" version="1.2"}% 1438 1797 ---+ Progressive Sexuality … … 1461 1820 %META:FIELD{name="FieldE" attributes="" title="Banother Field" value="$vE"}% 1462 1821 HERE 1463 my $topicObject=1464 Foswiki:: Meta->new( $this->{session}, $this->{test_web},1465 "QueryTopic$n", $text);1822 my ($topicObject) = 1823 Foswiki::Func::readTopic( $this->{test_web}, "QueryTopic$n", ); 1824 $topicObject->text($text); 1466 1825 $topicObject->save(); 1826 $topicObject->finish(); 1467 1827 } 1468 1828 require Benchmark; 1469 1829 1470 1830 # Search using a regular expression 1471 my $start = new Benchmark;1831 my $start = Benchmark->new(); 1472 1832 1473 1833 my $result = … … 1475 1835 '%SEARCH{"^[%]META:FIELD{name=\"FieldA\".*\bvalue=\"A\";^[%]META:FIELD{name=\"FieldB\".*\bvalue=\"A\";^[%]META:FIELD{name=\"FieldC\".*\bvalue=\"A\";^[%]META:FIELD{name=\"FieldD\".*\bvalue=\"A\"|^[%]META:FIELD{name=\"FieldE\".*\bvalue=\"A\"" type="regex" nonoise="on" format="$topic" separator=" "}%' 1476 1836 ); 1477 my $retime = Benchmark::timediff( new Benchmark, $start );1837 my $retime = Benchmark::timediff( Benchmark->new(), $start ); 1478 1838 $this->assert_str_equals( 'QueryTopic1 QueryTopic2', $result ); 1479 1839 1480 1840 # Repeat using a query 1481 $start = new Benchmark;1841 $start = Benchmark->new; 1482 1842 $result = 1483 1843 $this->{test_topicObject}->expandMacros( … … 1488 1848 print STDERR "Query " . Benchmark::timestr($querytime), 1489 1849 "\nRE " . Benchmark::timestr($retime), "\n"; 1490 } 1491 1492 sub verify_4347 { 1850 1851 return; 1852 } 1853 1854 sub test_4347 { 1493 1855 my $this = shift; 1494 1856 … … 1498 1860 ); 1499 1861 $this->assert_str_equals( '', $result ); 1862 1863 return; 1500 1864 } 1501 1865 … … 1515 1879 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1516 1880 1517 my $topicObject = 1518 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 1519 'QueryTopicTwo' ); 1881 my ($topicObject) = 1882 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 1520 1883 $result = 1521 1884 $topicObject->expandMacros( '%SEARCH{"text ~ \'*SMONG*\'" ' . $stdCrap ); 1522 1885 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1523 1886 1524 $topicObject =1525 Foswiki::Meta->new( $this->{session}, $this->{test_web},1526 'QueryTopicTwo' );1887 $topicObject->finish(); 1888 ($topicObject) = 1889 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 1527 1890 $result = $topicObject->expandMacros( 1528 1891 '%SEARCH{"text ~ \'*QueryTopicTwo*\'" ' . $stdCrap ); 1529 1892 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1530 1893 $topicObject->finish(); 1894 1895 return; 1531 1896 } 1532 1897 … … 1612 1977 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1613 1978 1614 my $topicObject = 1615 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 1616 'QueryTopicTwo' ); 1979 my ($topicObject) = 1980 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 1617 1981 $result = 1618 1982 $topicObject->expandMacros( '%SEARCH{"text ~ \'*SMONG*\'" web="' … … 1621 1985 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1622 1986 1623 $topicObject =1624 Foswiki::Meta->new( $this->{session}, $this->{test_web},1625 'QueryTopicTwo' );1987 $topicObject->finish(); 1988 ($topicObject) = 1989 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 1626 1990 $result = 1627 1991 $topicObject->expandMacros( '%SEARCH{"text ~ \'*QueryTopicTwo*\'" web="' … … 1630 1994 $this->assert_str_equals( 'QueryTopicTwo', $result ); 1631 1995 1632 $topicObject =1633 Foswiki::Meta->new( $this->{session}, $this->{test_web},1634 'QueryTopicTwo' );1996 $topicObject->finish(); 1997 ($topicObject) = 1998 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 1635 1999 $result = 1636 2000 $topicObject->expandMacros( '%SEARCH{"text ~ \'*Notinthetopics*\'" web="' … … 1638 2002 . $stdCrap ); 1639 2003 $this->assert_str_equals( '', $result ); 2004 $topicObject->finish(); 1640 2005 1641 2006 $result = … … 1645 2010 . $stdCrap ); 1646 2011 $this->assert_str_equals( 'QueryTopic', $result ); 1647 } 1648 1649 sub verify_pattern { 2012 2013 return; 2014 } 2015 2016 sub test_pattern { 1650 2017 my $this = shift; 1651 2018 … … 1657 2024 $this->assert_matches( qr/Xdont.matchmeY/, $result ); 1658 2025 $this->assert_matches( qr/XY/, $result ); 1659 } 1660 1661 sub verify_badpattern { 2026 2027 return; 2028 } 2029 2030 sub test_badpattern { 1662 2031 my $this = shift; 1663 2032 … … 1677 2046 # and format should be XY for all 3 topics 1678 2047 $this->assert_equals( 3, $result =~ s/^XY$//gm ); 1679 } 1680 1681 sub verify_validatepattern { 2048 2049 return; 2050 } 2051 2052 sub test_validatepattern { 1682 2053 my $this = shift; 1683 2054 my ( $pattern, $temp ); … … 1713 2084 $this->assert_matches( qr/$pattern/, 'foobluebar' ); 1714 2085 2086 return; 1715 2087 } 1716 2088 1717 2089 #Item977 1718 sub verify_formatOfLinks { 1719 my $this = shift; 1720 1721 my $topicObject = Foswiki::Meta->new( 1722 $this->{session}, 1723 $this->{test_web}, 'Item977', "---+ Apache 2090 sub test_formatOfLinks { 2091 my $this = shift; 2092 2093 my ($topicObject) = 2094 Foswiki::Func::readTopic( $this->{test_web}, 'Item977' ); 2095 $topicObject->text(<<'HERE'); 2096 ---+ Apache 1724 2097 1725 2098 Apache is the [[http://www.apache.org/httpd/][well known web server]]. 1726 " 1727 ); 2099 HERE 1728 2100 $topicObject->save(); 2101 $topicObject->finish(); 1729 2102 1730 2103 my $result = … … 1765 2138 ->TML2PlainText('Apache is the well known web server.') ); 1766 2139 2140 return; 1767 2141 } 1768 2142 1769 2143 sub _getTopicList { 1770 my $this = shift; 1771 my $web = shift; 1772 my $options = shift; 2144 my ( $this, $web, $options, $sadness, $default_expected, %expected_list ) = 2145 @_; 2146 my $expected = 2147 $this->_expect_with_deps( $default_expected, %expected_list ); 1773 2148 1774 2149 # my $options = { … … 1779 2154 # }; 1780 2155 2156 $this->assert_str_equals( 'ARRAY', ref($expected) ); 1781 2157 my $webObject = Foswiki::Meta->new( $this->{session}, $web ); 1782 2158 … … 1786 2162 Foswiki::Search::InfoCache::getTopicListIterator( $webObject, $options ); 1787 2163 1788 ASSERT( UNIVERSAL::isa( $iter, 'Foswiki::Iterator') ) if DEBUG;2164 ASSERT( $iter->isa('Foswiki::Iterator') ) if DEBUG; 1789 2165 my @topicList = (); 1790 2166 while ( my $t = $iter->next() ) { 2167 next if ( $t eq 'InvisibleTopic' ); #and user != admin or... 1791 2168 push( @topicList, $t ); 1792 2169 } 1793 2170 $webObject->finish(); 2171 2172 my $l1 = join( ',', @{$expected} ); 2173 my $l2 = join( ',', @topicList ); 2174 $this->assert_str_equals( $l1, $l2, "$sadness:\nwant: $l2\n got: $l1" ); 1794 2175 return \@topicList; 1795 2176 } … … 1799 2180 1800 2181 #no topics specified.. 1801 $this->assert_deep_equals( 2182 $this->_getTopicList( 2183 $this->{test_web}, 2184 {}, 2185 'no filters, all topics in test_web', 1802 2186 [ 1803 2187 'OkATopic', 'OkBTopic', … … 1805 2189 'WebPreferences' 1806 2190 ], 1807 $this->_getTopicList( $this->{test_web}, {} ), 1808 'no filters, all topics in test_web' 1809 ); 1810 $this->assert_deep_equals( 2191 ); 2192 $this->_getTopicList( 2193 '_default', 2194 {}, 2195 'no filters, all topics in test_web', 1811 2196 [ 1812 2197 'WebAtom', 'WebChanges', … … 1817 2202 'WebSearchAdvanced', 'WebTopicList' 1818 2203 ], 1819 $this->_getTopicList( '_default', {} ),1820 'no filters, all topics in _default web'1821 2204 ); 1822 2205 1823 2206 #use wildcards 1824 $this->assert_deep_equals( 2207 $this->_getTopicList( 2208 $this->{test_web}, 2209 { includeTopics => 'Ok*' }, 2210 'comma separated list', 1825 2211 [ 'OkATopic', 'OkBTopic', 'OkTopic' ], 1826 $this->_getTopicList( $this->{test_web}, { includeTopics => 'Ok*' } ), 1827 'test_web, Wildcard includeTopics Ok*' 1828 ); 1829 $this->assert_deep_equals( 2212 ); 2213 $this->_getTopicList( 2214 '_default', 2215 { includeTopics => 'Web*' }, 2216 'no filters, all topics in test_web', 1830 2217 [ 1831 2218 'WebAtom', 'WebChanges', … … 1836 2223 'WebSearchAdvanced', 'WebTopicList' 1837 2224 ], 1838 $this->_getTopicList( '_default', { includeTopics => 'Web*' } ),1839 '_default web, Wildcard includeTopics Web*'1840 2225 ); 1841 2226 1842 2227 #comma separated list specifed for inclusion 1843 $this->assert_deep_equals( 1844 [ 'TestTopicSEARCH', 'OkTopic' ], 1845 $this->_getTopicList( 1846 $this->{test_web}, 1847 { includeTopics => 'TestTopicSEARCH,OkTopic,NoSuchTopic' } 1848 ), 1849 'test_web, comma separated includeTopics, missing topic' 1850 ); 1851 $this->assert_deep_equals( 1852 [ 'WebTopicList', 'WebCreateNewTopic' ], 1853 $this->_getTopicList( 1854 '_default', 1855 { includeTopics => 'WebTopicList, WebCreateNewTopic, NoSuchTopic' } 1856 ), 1857 '_default web, comma-space separated includeTopics, missing topic ' 2228 $this->_getTopicList( 2229 $this->{test_web}, 2230 { includeTopics => 'TestTopicSEARCH,OkTopic,NoSuchTopic' }, 2231 'comma separated list', 2232 [ 'OkTopic', 'TestTopicSEARCH' ], 2233 'Foswiki,<,1.2' => [ 'TestTopicSEARCH', 'OkTopic' ], 2234 ); 2235 $this->_getTopicList( 2236 '_default', 2237 { includeTopics => 'WebTopicList, WebCreateNewTopic, NoSuchTopic' }, 2238 'no filters, all topics in test_web', 2239 [ 'WebCreateNewTopic', 'WebTopicList' ], 2240 'Foswiki,<,1.2' => [ 'WebTopicList', 'WebCreateNewTopic' ], 1858 2241 ); 1859 2242 1860 2243 #excludes 1861 $this->assert_deep_equals( 2244 $this->_getTopicList( 2245 $this->{test_web}, 2246 { excludeTopics => 'NoSuchTopic,OkBTopic' }, 2247 'no filters, all topics in test_web', 1862 2248 [ 'OkATopic', 'OkTopic', 'TestTopicSEARCH', 'WebPreferences' ], 1863 $this->_getTopicList( 1864 $this->{test_web}, { excludeTopics => 'NoSuchTopic,OkBTopic' } 1865 ), 1866 'test_web, comma separated excludeTopics list' 1867 ); 1868 $this->assert_deep_equals( 2249 ); 2250 $this->_getTopicList( 2251 '_default', 2252 { excludeTopics => 'WebSearch' }, 2253 'no filters, all topics in test_web', 1869 2254 [ 1870 2255 'WebAtom', 'WebChanges', … … 1875 2260 'WebTopicList' 1876 2261 ], 1877 $this->_getTopicList( '_default', { excludeTopics => 'WebSearch' } ),1878 '_default web, exclude WebSearch'1879 2262 ); 1880 2263 1881 2264 #Talk about missing alot of tests 1882 $this->assert_deep_equals( 2265 $this->_getTopicList( 2266 $this->{test_web}, 2267 { includeTopics => '*' }, 2268 'all topics, using wildcard', 1883 2269 [ 1884 2270 'OkATopic', 'OkBTopic', … … 1886 2272 'WebPreferences' 1887 2273 ], 1888 $this->_getTopicList( $this->{test_web}, { includeTopics => '*' } ), 1889 'all topics, using wildcard' 1890 ); 1891 $this->assert_deep_equals( 2274 ); 2275 $this->_getTopicList( 2276 $this->{test_web}, 2277 { includeTopics => 'Ok*' }, 2278 'Ok* topics, using wildcard', 1892 2279 [ 'OkATopic', 'OkBTopic', 'OkTopic' ], 1893 $this->_getTopicList( $this->{test_web}, { includeTopics => 'Ok*' } ), 1894 'Ok* topics, using wildcard' 1895 ); 1896 $this->assert_deep_equals( 2280 ); 2281 $this->_getTopicList( 2282 $this->{test_web}, 2283 { 2284 includeTopics => 'ok*', 2285 casesensitive => 1 2286 }, 2287 'case sensitive ok* topics, using wildcard', 1897 2288 [], 1898 $this->_getTopicList( 1899 $this->{test_web}, 1900 { 1901 includeTopics => 'ok*', 1902 casesensitive => 1 1903 } 1904 ), 1905 'case sensitive ok* topics, using wildcard' 1906 ); 1907 $this->assert_deep_equals( 2289 ); 2290 $this->_getTopicList( 2291 $this->{test_web}, 2292 { 2293 includeTopics => 'ok*', 2294 casesensitive => 0 2295 }, 2296 'case insensitive ok* topics, using wildcard', 1908 2297 [ 'OkATopic', 'OkBTopic', 'OkTopic' ], 1909 $this->_getTopicList(1910 $this->{test_web},1911 {1912 includeTopics => 'ok*',1913 casesensitive => 01914 }1915 ),1916 'case insensitive ok* topics, using wildcard'1917 2298 ); 1918 2299 … … 1923 2304 1924 2305 # this test won't work on Mac OS X or windows. 1925 $this->assert_deep_equals(1926 [],1927 $this->_getTopicList(1928 $this->{test_web},1929 {1930 includeTopics => 'okatopic',1931 casesensitive => 11932 }1933 ),1934 'case sensitive okatopic topic 1'1935 );1936 }1937 1938 $this->assert_deep_equals(1939 ['OkATopic'],1940 2306 $this->_getTopicList( 1941 2307 $this->{test_web}, 1942 2308 { 1943 2309 includeTopics => 'okatopic', 1944 casesensitive => 0 1945 } 1946 ), 1947 'case insensitive okatopic topic' 2310 casesensitive => 1 2311 }, 2312 'case sensitive okatopic topic 1', 2313 [], 2314 ); 2315 } 2316 2317 $this->_getTopicList( 2318 $this->{test_web}, 2319 { 2320 includeTopics => 'okatopic', 2321 casesensitive => 0 2322 }, 2323 'case insensitive okatopic topic', 2324 ['OkATopic'], 1948 2325 ); 1949 2326 ##### same again, with excludes. 1950 $this->assert_deep_equals( 2327 $this->_getTopicList( 2328 $this->{test_web}, 2329 { 2330 includeTopics => '*', 2331 excludeTopics => 'web*' 2332 }, 2333 'all topics, using wildcard', 1951 2334 [ 1952 2335 'OkATopic', 'OkBTopic', … … 1954 2337 'WebPreferences' 1955 2338 ], 1956 $this->_getTopicList( 1957 $this->{test_web}, 1958 { 1959 includeTopics => '*', 1960 excludeTopics => 'web*' 1961 } 1962 ), 1963 'all topics, using wildcard' 1964 ); 1965 $this->assert_deep_equals( 2339 ); 2340 $this->_getTopicList( 2341 $this->{test_web}, 2342 { 2343 includeTopics => 'Ok*', 2344 excludeTopics => 'okatopic' 2345 }, 2346 'Ok* topics, using wildcard', 1966 2347 [ 'OkATopic', 'OkBTopic', 'OkTopic' ], 1967 $this->_getTopicList( 1968 $this->{test_web}, 1969 { 1970 includeTopics => 'Ok*', 1971 excludeTopics => 'okatopic' 1972 } 1973 ), 1974 'Ok* topics, using wildcard' 1975 ); 1976 $this->assert_deep_equals( 2348 ); 2349 $this->_getTopicList( 2350 $this->{test_web}, 2351 { 2352 includeTopics => 'ok*', 2353 excludeTopics => 'WebPreferences', 2354 casesensitive => 1 2355 }, 2356 'case sensitive ok* topics, using wildcard', 1977 2357 [], 1978 $this->_getTopicList( 1979 $this->{test_web}, 1980 { 1981 includeTopics => 'ok*', 1982 excludeTopics => 'WebPreferences', 1983 casesensitive => 1 1984 } 1985 ), 1986 'case sensitive ok* topics, using wildcard' 1987 ); 1988 $this->assert_deep_equals( 2358 ); 2359 $this->_getTopicList( 2360 $this->{test_web}, 2361 { 2362 includeTopics => 'ok*', 2363 excludeTopics => '', 2364 casesensitive => 0 2365 }, 2366 'case insensitive ok* topics, using wildcard', 1989 2367 [ 'OkATopic', 'OkBTopic', 'OkTopic' ], 1990 $this->_getTopicList( 1991 $this->{test_web}, 1992 { 1993 includeTopics => 'ok*', 1994 excludeTopics => '', 1995 casesensitive => 0 1996 } 1997 ), 1998 'case insensitive ok* topics, using wildcard' 1999 ); 2000 2001 $this->assert_deep_equals( 2368 ); 2369 2370 $this->_getTopicList( 2371 $this->{test_web}, 2372 { 2373 includeTopics => 'Ok*', 2374 excludeTopics => '*ATopic', 2375 casesensitive => 1 2376 }, 2377 'case sensitive okatopic topic 2', 2002 2378 [ 'OkBTopic', 'OkTopic' ], 2003 $this->_getTopicList( 2004 $this->{test_web}, 2005 { 2006 includeTopics => 'Ok*', 2007 excludeTopics => '*ATopic', 2008 casesensitive => 1 2009 } 2010 ), 2011 'case sensitive okatopic topic 2' 2012 ); 2013 2014 $this->assert_deep_equals( 2379 ); 2380 2381 $this->_getTopicList( 2382 $this->{test_web}, 2383 { 2384 includeTopics => 'Ok*', 2385 excludeTopics => '*atopic', 2386 casesensitive => 1 2387 }, 2388 'case sensitive okatopic topic 3', 2015 2389 [ 'OkATopic', 'OkBTopic', 'OkTopic' ], 2016 $this->_getTopicList( 2017 $this->{test_web}, 2018 { 2019 includeTopics => 'Ok*', 2020 excludeTopics => '*atopic', 2021 casesensitive => 1 2022 } 2023 ), 2024 'case sensitive okatopic topic 3' 2025 ); 2026 2027 $this->assert_deep_equals( 2390 ); 2391 2392 $this->_getTopicList( 2393 $this->{test_web}, 2394 { 2395 includeTopics => 'ok*topic', 2396 excludeTopics => 'okatopic', 2397 casesensitive => 0 2398 }, 2399 'case insensitive okatopic topic', 2028 2400 [ 'OkBTopic', 'OkTopic' ], 2029 $this->_getTopicList( 2030 $this->{test_web}, 2031 { 2032 includeTopics => 'ok*topic', 2033 excludeTopics => 'okatopic', 2034 casesensitive => 0 2035 } 2036 ), 2037 'case insensitive okatopic topic' 2038 ); 2039 2401 ); 2402 2403 return; 2040 2404 } 2041 2405 … … 2111 2475 $this->assert_str_equals( $expected, $actual ); 2112 2476 2477 return; 2113 2478 } 2114 2479 … … 2116 2481 my $this = shift; 2117 2482 2118 my $topicObject=2119 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'TestForm',2120 <<'FORM');2483 my ($topicObject) = 2484 Foswiki::Func::readTopic( $this->{test_web}, 'TestForm' ); 2485 $topicObject->text(<<'FORM'); 2121 2486 | *Name* | *Type* | *Size* | *Value* | *Tooltip message* | *Attributes* | 2122 2487 | Why | text | 32 | | Mandatory field | M | … … 2124 2489 FORM 2125 2490 $topicObject->save(); 2126 $topicObject = 2127 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'SplodgeOne', 2128 <<FORM); 2491 $topicObject->finish(); 2492 ($topicObject) = 2493 Foswiki::Func::readTopic( $this->{test_web}, 'SplodgeOne' ); 2494 $topicObject->text( <<'FORM'); 2129 2495 %META:FORM{name="TestForm"}% 2130 2496 %META:FIELD{name="Ecks" attributes="" title="X" value="Blah"}% … … 2137 2503 my $expected = 'SplodgeOne;Blah'; 2138 2504 $this->assert_str_equals( $expected, $actual ); 2139 2505 $topicObject->finish(); 2506 2507 return; 2140 2508 } 2141 2509 … … 2143 2511 my $this = shift; 2144 2512 2145 my $topicObject=2146 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'TestForm',2147 <<'FORM');2513 my ($topicObject) = 2514 Foswiki::Func::readTopic( $this->{test_web}, 'TestForm' ); 2515 $topicObject->text( <<'FORM'); 2148 2516 | *Name* | *Type* | *Size* | *Value* | *Tooltip message* | *Attributes* | 2149 2517 | Why | text | 32 | | Mandatory field | M | … … 2151 2519 FORM 2152 2520 $topicObject->save(); 2153 $topicObject = 2154 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'SplodgeOne', 2155 <<FORM); 2521 $topicObject->finish(); 2522 ($topicObject) = 2523 Foswiki::Func::readTopic( $this->{test_web}, 'SplodgeOne' ); 2524 $topicObject->text(<<'FORM'); 2156 2525 %META:FORM{name="TestForm"}% 2157 2526 %META:FIELD{name="Ecks" attributes="" title="X" value="Blah"}% … … 2164 2533 my $expected = 'SplodgeOne;Blah'; 2165 2534 $this->assert_str_equals( $expected, $actual ); 2166 2535 $topicObject->finish(); 2536 2537 return; 2167 2538 } 2168 2539 … … 2188 2559 HERE 2189 2560 $this->assert_str_equals( $expected, $actual ); 2561 2562 return; 2190 2563 } 2191 2564 … … 2195 2568 #need summary, and multiple 2196 2569 sub _multiWebSeptic { 2197 my ( $this, $head, $foot, $sep, $results, $expected, $format ) = @_; 2570 my ( $this, $head, $foot, $sep, $results, $format, $default, %expectations ) 2571 = @_; 2198 2572 my $str = $results ? '*Preferences' : 'Septic'; 2199 2573 $head = $head ? 'header="HEAD($web)"' : ''; … … 2201 2575 $sep = defined $sep ? "separator=\"$sep\"" : ''; 2202 2576 $format = '$topic' unless ( defined($format) ); 2577 my $expected = $this->_expect_with_deps( $default, %expectations ); 2203 2578 2204 2579 my $result = $this->{test_topicObject}->expandMacros( … … 2214 2589 $expected =~ s/\n$//s; 2215 2590 $this->assert_str_equals( $expected, $result ); 2591 2592 return; 2216 2593 } 2217 2594 2218 2595 ##################### 2219 2596 2220 sub verify_multiWeb_no_header_no_footer_no_separator_with_results { 2221 my $this = shift; 2222 $this->_multiWebSeptic( 0, 0, undef, 1, <<EXPECT); 2597 sub test_multiWeb_no_header_no_footer_no_separator_with_results { 2598 my $this = shift; 2599 $this->_multiWebSeptic( 2600 0, 0, undef, 1, undef, <<'FOSWIKI12', 2601 SitePreferences 2602 WebPreferences 2603 DefaultPreferences 2604 WebPreferences 2605 FOSWIKI12 2606 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2223 2607 DefaultPreferences 2224 2608 WebPreferences 2225 2609 SitePreferences 2226 2610 WebPreferences 2227 EXPECT 2228 } 2229 2230 sub verify_multiWeb_no_header_no_footer_no_separator_with_results_counters { 2231 my $this = shift; 2232 $this->_multiWebSeptic( 0, 0, undef, 1, 2233 <<EXPECT, '$nhits, $ntopics, $index, $topic' ); 2611 FOSWIKI11 2612 2613 return; 2614 } 2615 2616 sub test_multiWeb_no_header_no_footer_no_separator_with_results_counters { 2617 my $this = shift; 2618 $this->_multiWebSeptic( 2619 0, 0, undef, 1, 2620 '$nhits, $ntopics, $index, $topic', <<'FOSWIKI12', 2621 1, 1, 1, SitePreferences 2622 2, 2, 2, WebPreferences 2623 1, 1, 3, DefaultPreferences 2624 2, 2, 4, WebPreferences 2625 FOSWIKI12 2626 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2234 2627 1, 1, 1, DefaultPreferences 2235 2628 2, 2, 2, WebPreferences 2236 2629 1, 1, 3, SitePreferences 2237 2630 2, 2, 4, WebPreferences 2238 EXPECT 2239 } 2240 2241 sub verify_multiWeb_no_header_no_footer_no_separator_no_results { 2242 my $this = shift; 2243 $this->_multiWebSeptic( 0, 0, undef, 0, <<EXPECT); 2244 EXPECT 2245 } 2246 2247 sub verify_multiWeb_no_header_no_footer_empty_separator_with_results { 2248 my $this = shift; 2249 $this->_multiWebSeptic( 0, 0, "", 1, <<EXPECT); 2631 FOSWIKI11 2632 2633 return; 2634 } 2635 2636 sub test_multiWeb_no_header_no_footer_no_separator_no_results { 2637 my $this = shift; 2638 $this->_multiWebSeptic( 0, 0, undef, 0, undef, <<'FOSWIKI12'); 2639 FOSWIKI12 2640 2641 return; 2642 } 2643 2644 sub test_multiWeb_no_header_no_footer_empty_separator_with_results { 2645 my $this = shift; 2646 $this->_multiWebSeptic( 2647 0, 0, "", 1, undef, <<'FOSWIKI12', 2648 SitePreferencesWebPreferencesDefaultPreferencesWebPreferences 2649 FOSWIKI12 2650 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2250 2651 DefaultPreferencesWebPreferencesSitePreferencesWebPreferences 2251 EXPECT 2252 } 2253 2254 sub verify_multiWeb_no_header_no_footer_empty_separator_no_results { 2255 my $this = shift; 2256 $this->_multiWebSeptic( 0, 0, "", 0, <<EXPECT); 2257 EXPECT 2258 } 2259 2260 sub verify_multiWeb_no_header_no_footer_with_separator_with_results { 2261 my $this = shift; 2262 $this->_multiWebSeptic( 0, 0, ",", 1, <<EXPECT); 2652 FOSWIKI11 2653 2654 return; 2655 } 2656 2657 sub test_multiWeb_no_header_no_footer_empty_separator_no_results { 2658 my $this = shift; 2659 $this->_multiWebSeptic( 0, 0, "", 0, undef, <<'FOSWIKI12'); 2660 FOSWIKI12 2661 2662 return; 2663 } 2664 2665 sub test_multiWeb_no_header_no_footer_with_separator_with_results { 2666 my $this = shift; 2667 $this->_multiWebSeptic( 2668 0, 0, ",", 1, undef, <<'FOSWIKI12', 2669 SitePreferences,WebPreferences,DefaultPreferences,WebPreferences 2670 FOSWIKI12 2671 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2263 2672 DefaultPreferences,WebPreferences,SitePreferences,WebPreferences 2264 EXPECT 2265 } 2266 2267 sub verify_multiWeb_no_header_no_footer_with_separator_no_results { 2268 my $this = shift; 2269 $this->_multiWebSeptic( 0, 0, ",", 0, <<EXPECT); 2270 EXPECT 2673 FOSWIKI11 2674 2675 return; 2676 } 2677 2678 sub test_multiWeb_no_header_no_footer_with_separator_no_results { 2679 my $this = shift; 2680 $this->_multiWebSeptic( 0, 0, ",", 0, undef, <<'FOSWIKI12'); 2681 FOSWIKI12 2682 2683 return; 2271 2684 } 2272 2685 ##################### 2273 2686 2274 sub verify_multiWeb_no_header_with_footer_no_separator_with_results { 2275 my $this = shift; 2276 $this->_multiWebSeptic( 0, 1, undef, 1, <<EXPECT); 2687 sub test_multiWeb_no_header_with_footer_no_separator_with_results { 2688 my $this = shift; 2689 $this->_multiWebSeptic( 2690 0, 1, undef, 1, undef, <<'FOSWIKI12', 2691 SitePreferences 2692 WebPreferences 2693 FOOT(2,2)DefaultPreferences 2694 WebPreferences 2695 FOOT(2,2) 2696 FOSWIKI12 2697 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2277 2698 DefaultPreferences 2278 2699 WebPreferences … … 2280 2701 WebPreferences 2281 2702 FOOT(2,2) 2282 EXPECT 2283 } 2284 2285 sub verify_multiWeb_no_header_with_footer_no_separator_no_results { 2286 my $this = shift; 2287 $this->_multiWebSeptic( 0, 1, undef, 0, <<EXPECT); 2288 EXPECT 2289 } 2290 2291 sub verify_multiWeb_no_header_with_footer_empty_separator_with_results { 2292 my $this = shift; 2293 $this->_multiWebSeptic( 0, 1, "", 1, <<EXPECT); 2703 FOSWIKI11 2704 2705 return; 2706 } 2707 2708 sub test_multiWeb_no_header_with_footer_no_separator_no_results { 2709 my $this = shift; 2710 $this->_multiWebSeptic( 0, 1, undef, 0, undef, <<'FOSWIKI12'); 2711 FOSWIKI12 2712 2713 return; 2714 } 2715 2716 sub test_multiWeb_no_header_with_footer_empty_separator_with_results { 2717 my $this = shift; 2718 $this->_multiWebSeptic( 2719 0, 1, "", 1, undef, <<'FOSWIKI12', 2720 SitePreferencesWebPreferencesFOOT(2,2)DefaultPreferencesWebPreferencesFOOT(2,2) 2721 FOSWIKI12 2722 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2294 2723 DefaultPreferencesWebPreferencesFOOT(2,2)SitePreferencesWebPreferencesFOOT(2,2) 2295 EXPECT 2296 } 2297 2298 sub verify_multiWeb_no_header_with_footer_empty_separator_no_results { 2299 my $this = shift; 2300 $this->_multiWebSeptic( 0, 1, "", 0, <<EXPECT); 2301 EXPECT 2302 } 2303 2304 sub verify_multiWeb_no_header_with_footer_with_separator_with_results { 2305 my $this = shift; 2306 $this->_multiWebSeptic( 0, 1, ",", 1, <<EXPECT); 2724 FOSWIKI11 2725 2726 return; 2727 } 2728 2729 sub test_multiWeb_no_header_with_footer_empty_separator_no_results { 2730 my $this = shift; 2731 $this->_multiWebSeptic( 0, 1, "", 0, undef, <<'FOSWIKI12'); 2732 FOSWIKI12 2733 2734 return; 2735 } 2736 2737 sub test_multiWeb_no_header_with_footer_with_separator_with_results { 2738 my $this = shift; 2739 $this->_multiWebSeptic( 2740 0, 1, ",", 1, undef, <<'FOSWIKI12', 2741 SitePreferences,WebPreferencesFOOT(2,2)DefaultPreferences,WebPreferencesFOOT(2,2) 2742 FOSWIKI12 2743 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2307 2744 DefaultPreferences,WebPreferencesFOOT(2,2)SitePreferences,WebPreferencesFOOT(2,2) 2308 EXPECT 2745 FOSWIKI11 2746 2747 return; 2309 2748 } 2310 2749 2311 2750 ##################### 2312 2751 2313 sub verify_multiWeb_with_header_with_footer_no_separator_with_results { 2314 my $this = shift; 2315 $this->_multiWebSeptic( 1, 1, undef, 1, <<EXPECT); 2752 sub test_multiWeb_with_header_with_footer_no_separator_with_results { 2753 my $this = shift; 2754 $this->_multiWebSeptic( 2755 1, 1, undef, 1, undef, <<'FOSWIKI12', 2756 HEAD(Main) 2757 SitePreferences 2758 WebPreferences 2759 FOOT(2,2)HEAD(System) 2760 DefaultPreferences 2761 WebPreferences 2762 FOOT(2,2) 2763 FOSWIKI12 2764 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2316 2765 HEAD(System) 2317 2766 DefaultPreferences … … 2321 2770 WebPreferences 2322 2771 FOOT(2,2) 2323 EXPECT 2324 } 2325 2326 sub verify_multiWeb_with_header_with_footer_no_separator_no_results { 2327 my $this = shift; 2328 $this->_multiWebSeptic( 1, 1, undef, 0, <<EXPECT); 2329 EXPECT 2330 } 2331 2332 sub verify_multiWeb_with_header_with_footer_empty_separator_with_results { 2333 my $this = shift; 2334 $this->_multiWebSeptic( 1, 1, "", 1, <<EXPECT); 2772 FOSWIKI11 2773 2774 return; 2775 } 2776 2777 sub test_multiWeb_with_header_with_footer_no_separator_no_results { 2778 my $this = shift; 2779 $this->_multiWebSeptic( 1, 1, undef, 0, undef, <<'FOSWIKI12'); 2780 FOSWIKI12 2781 2782 return; 2783 } 2784 2785 sub test_multiWeb_with_header_with_footer_empty_separator_with_results { 2786 my $this = shift; 2787 $this->_multiWebSeptic( 2788 1, 1, "", 1, undef, <<'FOSWIKI12', 2789 HEAD(Main)SitePreferencesWebPreferencesFOOT(2,2)HEAD(System)DefaultPreferencesWebPreferencesFOOT(2,2) 2790 FOSWIKI12 2791 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2335 2792 HEAD(System)DefaultPreferencesWebPreferencesFOOT(2,2)HEAD(Main)SitePreferencesWebPreferencesFOOT(2,2) 2336 EXPECT 2337 } 2338 2339 sub verify_multiWeb_with_header_with_footer_empty_separator_no_results { 2340 my $this = shift; 2341 $this->_multiWebSeptic( 1, 1, "", 0, <<EXPECT); 2342 EXPECT 2343 } 2344 2345 sub verify_multiWeb_with_header_with_footer_with_separator_with_results { 2346 my $this = shift; 2347 $this->_multiWebSeptic( 1, 1, ",", 1, <<EXPECT); 2793 FOSWIKI11 2794 2795 return; 2796 } 2797 2798 sub test_multiWeb_with_header_with_footer_empty_separator_no_results { 2799 my $this = shift; 2800 $this->_multiWebSeptic( 1, 1, "", 0, undef, <<'FOSWIKI12'); 2801 FOSWIKI12 2802 2803 return; 2804 } 2805 2806 sub test_multiWeb_with_header_with_footer_with_separator_with_results { 2807 my $this = shift; 2808 $this->_multiWebSeptic( 2809 1, 1, ",", 1, undef, <<'FOSWIKI12', 2810 HEAD(Main)SitePreferences,WebPreferencesFOOT(2,2)HEAD(System)DefaultPreferences,WebPreferencesFOOT(2,2) 2811 FOSWIKI12 2812 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2348 2813 HEAD(System)DefaultPreferences,WebPreferencesFOOT(2,2)HEAD(Main)SitePreferences,WebPreferencesFOOT(2,2) 2349 EXPECT 2350 } 2351 2352 sub verify_multiWeb_with_header_with_footer_with_separator_no_results { 2353 my $this = shift; 2354 $this->_multiWebSeptic( 1, 1, ",", 0, <<EXPECT); 2355 EXPECT 2814 FOSWIKI11 2815 2816 return; 2817 } 2818 2819 sub test_multiWeb_with_header_with_footer_with_separator_no_results { 2820 my $this = shift; 2821 $this->_multiWebSeptic( 1, 1, ",", 0, undef, <<'FOSWIKI12'); 2822 FOSWIKI12 2823 2824 return; 2356 2825 } 2357 2826 2358 2827 ##################### 2359 2828 2360 sub verify_multiWeb_with_header_no_footer_no_separator_with_results { 2361 my $this = shift; 2362 $this->_multiWebSeptic( 1, 0, undef, 1, <<EXPECT); 2829 sub test_multiWeb_with_header_no_footer_no_separator_with_results { 2830 my $this = shift; 2831 $this->_multiWebSeptic( 2832 1, 0, undef, 1, undef, <<'FOSWIKI12', 2833 HEAD(Main) 2834 SitePreferences 2835 WebPreferences 2836 HEAD(System) 2837 DefaultPreferences 2838 WebPreferences 2839 FOSWIKI12 2840 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2363 2841 HEAD(System) 2364 2842 DefaultPreferences … … 2367 2845 SitePreferences 2368 2846 WebPreferences 2369 EXPECT 2370 } 2371 2372 sub verify_multiWeb_with_header_no_footer_no_separator_no_results { 2373 my $this = shift; 2374 $this->_multiWebSeptic( 1, 0, undef, 0, <<EXPECT); 2375 EXPECT 2376 } 2377 2378 sub verify_multiWeb_with_header_no_footer_empty_separator_with_results { 2379 my $this = shift; 2380 $this->_multiWebSeptic( 1, 0, "", 1, <<EXPECT); 2847 FOSWIKI11 2848 2849 return; 2850 } 2851 2852 sub test_multiWeb_with_header_no_footer_no_separator_no_results { 2853 my $this = shift; 2854 $this->_multiWebSeptic( 1, 0, undef, 0, undef, <<'FOSWIKI12'); 2855 FOSWIKI12 2856 2857 return; 2858 } 2859 2860 sub test_multiWeb_with_header_no_footer_empty_separator_with_results { 2861 my $this = shift; 2862 $this->_multiWebSeptic( 2863 1, 0, "", 1, undef, <<'FOSWIKI12', 2864 HEAD(Main)SitePreferencesWebPreferencesHEAD(System)DefaultPreferencesWebPreferences 2865 FOSWIKI12 2866 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2381 2867 HEAD(System)DefaultPreferencesWebPreferencesHEAD(Main)SitePreferencesWebPreferences 2382 EXPECT 2383 } 2384 2385 sub verify_multiWeb_with_header_no_footer_empty_separator_no_results { 2386 my $this = shift; 2387 $this->_multiWebSeptic( 1, 0, "", 0, <<EXPECT); 2388 EXPECT 2389 } 2390 2391 sub verify_multiWeb_with_header_no_footer_with_separator_with_results { 2392 my $this = shift; 2393 $this->_multiWebSeptic( 1, 0, ",", 1, <<EXPECT); 2868 FOSWIKI11 2869 2870 return; 2871 } 2872 2873 sub test_multiWeb_with_header_no_footer_empty_separator_no_results { 2874 my $this = shift; 2875 $this->_multiWebSeptic( 1, 0, "", 0, undef, <<'FOSWIKI12'); 2876 FOSWIKI12 2877 2878 return; 2879 } 2880 2881 sub test_multiWeb_with_header_no_footer_with_separator_with_results { 2882 my $this = shift; 2883 $this->_multiWebSeptic( 2884 1, 0, ",", 1, undef, <<'FOSWIKI12', 2885 HEAD(Main)SitePreferences,WebPreferencesHEAD(System)DefaultPreferences,WebPreferences 2886 FOSWIKI12 2887 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2394 2888 HEAD(System)DefaultPreferences,WebPreferencesHEAD(Main)SitePreferences,WebPreferences 2395 EXPECT 2396 } 2397 2398 sub verify_multiWeb_with_header_no_footer_with_separator_no_results { 2399 my $this = shift; 2400 $this->_multiWebSeptic( 1, 0, ",", 0, <<EXPECT); 2401 EXPECT 2889 FOSWIKI11 2890 2891 return; 2892 } 2893 2894 sub test_multiWeb_with_header_no_footer_with_separator_no_results { 2895 my $this = shift; 2896 $this->_multiWebSeptic( 1, 0, ",", 0, undef, <<'FOSWIKI12'); 2897 FOSWIKI12 2898 2899 return; 2402 2900 } 2403 2901 2404 2902 #Item1992: calling Foswiki::Search::_makeTopicPattern repeatedly made a big mess. 2405 sub verify_web_and_topic_expansion {2903 sub test_web_and_topic_expansion { 2406 2904 my $this = shift; 2407 2905 my $result = $this->{test_topicObject}->expandMacros( … … 2417 2915 }%' 2418 2916 ); 2419 my $expected = <<EXPECT; 2917 my $expected = $this->_expect_with_deps( 2918 <<'FOSWIKI12', 2919 Main.WebHome 2920 Main.WebPreferences 2921 FOOT(2,2)Sandbox.WebHome 2922 Sandbox.WebPreferences 2923 FOOT(2,2)System.WebHome 2924 System.WebPreferences 2925 FOOT(2,2) 2926 FOSWIKI12 2927 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2420 2928 System.WebHome 2421 2929 System.WebPreferences … … 2425 2933 Sandbox.WebPreferences 2426 2934 FOOT(2,2) 2427 EXPECT 2935 FOSWIKI11 2428 2936 $expected =~ s/\n$//s; 2429 2937 $this->assert_str_equals( $expected, $result ); 2938 2939 return; 2430 2940 } 2431 2941 2432 2942 ##################### 2433 2943 # PAGING 2434 sub verify_paging_three_webs_first_five { 2435 my $this = shift; 2436 2944 sub test_paging_three_webs_first_page { 2945 my $this = shift; 2437 2946 my $result = $this->{test_topicObject}->expandMacros( 2438 2947 '%SEARCH{ … … 2450 2959 ); 2451 2960 2452 my $expected = <<EXPECT; 2961 my $expected = $this->_expect_with_deps( 2962 <<'FOSWIKI12', 2963 Main.WebChanges 2964 Main.WebHome 2965 Main.WebIndex 2966 Main.WebPreferences 2967 FOOT(4,4)Sandbox.WebChanges 2968 FOOT(1,1) 2969 FOSWIKI12 2970 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2453 2971 System.WebChanges 2454 2972 System.WebHome … … 2457 2975 FOOT(4,4)Main.WebChanges 2458 2976 FOOT(1,1) 2459 EXPECT 2977 FOSWIKI11 2460 2978 $expected =~ s/\n$//s; 2461 2979 $this->assert_str_equals( $expected, $result ); 2462 } 2463 2464 sub verify_paging_three_webs_second_five { 2980 2981 return; 2982 } 2983 2984 sub test_paging_three_webs_second_page { 2465 2985 my $this = shift; 2466 2986 … … 2480 3000 ); 2481 3001 2482 my $expected = <<EXPECT; 3002 my $expected = $this->_expect_with_deps( 3003 <<'FOSWIKI12', 3004 Sandbox.WebHome 3005 Sandbox.WebIndex 3006 Sandbox.WebPreferences 3007 FOOT(3,3)System.WebChanges 3008 System.WebHome 3009 FOOT(2,2) 3010 FOSWIKI12 3011 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2483 3012 Main.WebHome 2484 3013 Main.WebIndex … … 2487 3016 Sandbox.WebHome 2488 3017 FOOT(2,2) 2489 EXPECT 3018 FOSWIKI11 2490 3019 $expected =~ s/\n$//s; 2491 3020 $this->assert_str_equals( $expected, $result ); 2492 } 2493 2494 sub verify_paging_three_webs_third_five { 3021 3022 return; 3023 } 3024 3025 sub test_paging_three_webs_third_page { 2495 3026 my $this = shift; 2496 3027 … … 2510 3041 ); 2511 3042 2512 my $expected = <<EXPECT; 3043 my $expected = $this->_expect_with_deps( 3044 <<'FOSWIKI12', 3045 System.WebIndex 3046 System.WebPreferences 3047 FOOT(2,2) 3048 FOSWIKI12 3049 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2513 3050 Sandbox.WebIndex 2514 3051 Sandbox.WebPreferences 2515 3052 FOOT(2,2) 2516 EXPECT 3053 FOSWIKI11 2517 3054 $expected =~ s/\n$//s; 2518 3055 $this->assert_str_equals( $expected, $result ); 2519 } 2520 2521 sub verify_paging_three_webs_fourth_five { 3056 3057 return; 3058 } 3059 3060 sub test_paging_three_webs_fourth_page { 2522 3061 my $this = shift; 2523 3062 … … 2537 3076 ); 2538 3077 2539 my $expected = << EXPECT;3078 my $expected = <<'EXPECT'; 2540 3079 EXPECT 2541 3080 $expected =~ s/\n$//s; 2542 3081 $this->assert_str_equals( $expected, $result ); 2543 } 2544 2545 sub verify_paging_three_webs_way_too_far { 3082 3083 return; 3084 } 3085 3086 sub test_paging_three_webs_way_too_far { 2546 3087 my $this = shift; 2547 3088 … … 2561 3102 ); 2562 3103 2563 my $expected = << EXPECT;3104 my $expected = <<'EXPECT'; 2564 3105 EXPECT 2565 3106 $expected =~ s/\n$//s; 2566 3107 $this->assert_str_equals( $expected, $result ); 3108 3109 return; 2567 3110 } 2568 3111 … … 2586 3129 }%' 2587 3130 ); 2588 2589 my $expected = <<EXPECT; 3131 my $expected = $this->_expect_with_deps( 3132 <<'FOSWIKI12', 3133 Main.WebPreferences 3134 FOOT(1,1) 3135 Sandbox.WebPreferences 3136 FOOT(1,1) 3137 System.WebPreferences 3138 FOOT(1,1) 3139 FOSWIKI12 3140 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2590 3141 System.WebPreferences 2591 3142 FOOT(1,1) … … 2594 3145 Sandbox.WebPreferences 2595 3146 FOOT(1,1) 2596 EXPECT 3147 FOSWIKI11 3148 2597 3149 $expected =~ s/\n$//s; 2598 3150 $this->assert_str_equals( $expected, $result ); 3151 3152 return; 2599 3153 } 2600 3154 2601 3155 #------------------------------------ 2602 3156 # PAGING with limit= does weird things. 2603 sub verify_paging_with_limit_first_five {3157 sub test_paging_with_limit_first_page { 2604 3158 my $this = shift; 2605 3159 … … 2620 3174 ); 2621 3175 2622 my $expected = <<EXPECT; 3176 my $expected = $this->_expect_with_deps( 3177 <<'FOSWIKI12', 3178 Main.WebChanges 3179 Main.WebHome 3180 Main.WebIndex 3181 FOOT(3,3) 3182 FOSWIKI12 3183 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2623 3184 System.WebChanges 2624 3185 System.WebHome 2625 3186 System.WebIndex 2626 3187 FOOT(3,3) 2627 EXPECT 3188 FOSWIKI11 2628 3189 $expected =~ s/\n$//s; 2629 3190 $this->assert_str_equals( $expected, $result ); 2630 } 2631 2632 sub verify_paging_with_limit_second_five { 3191 3192 return; 3193 } 3194 3195 sub test_paging_with_limit_second_page { 2633 3196 my $this = shift; 2634 3197 … … 2649 3212 ); 2650 3213 2651 my $expected = <<EXPECT; 3214 my $expected = $this->_expect_with_deps( 3215 <<'FOSWIKI12', 3216 Sandbox.WebChanges 3217 Sandbox.WebHome 3218 Sandbox.WebIndex 3219 FOOT(3,3) 3220 FOSWIKI12 3221 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2652 3222 Main.WebChanges 2653 3223 Main.WebHome 2654 3224 Main.WebIndex 2655 3225 FOOT(3,3) 2656 EXPECT 3226 FOSWIKI11 2657 3227 $expected =~ s/\n$//s; 2658 3228 $this->assert_str_equals( $expected, $result ); 2659 } 2660 2661 sub verify_paging_with_limit_third_five { 3229 3230 return; 3231 } 3232 3233 sub test_paging_with_limit_third_page { 2662 3234 my $this = shift; 2663 3235 … … 2678 3250 ); 2679 3251 2680 my $expected = <<EXPECT; 3252 my $expected = $this->_expect_with_deps( 3253 <<'FOSWIKI12', 3254 System.WebChanges 3255 System.WebHome 3256 System.WebIndex 3257 FOOT(3,3) 3258 FOSWIKI12 3259 'Foswiki,<,1.2' => <<'FOSWIKI11'); 2681 3260 Sandbox.WebChanges 2682 3261 Sandbox.WebHome 2683 3262 Sandbox.WebIndex 2684 3263 FOOT(3,3) 2685 EXPECT 3264 FOSWIKI11 2686 3265 $expected =~ s/\n$//s; 2687 3266 $this->assert_str_equals( $expected, $result ); 2688 } 2689 2690 sub verify_paging_with_limit_fourth_five { 3267 3268 return; 3269 } 3270 3271 sub test_paging_with_limit_fourth_page { 2691 3272 my $this = shift; 2692 3273 … … 2707 3288 ); 2708 3289 2709 my $expected = << EXPECT;3290 my $expected = <<'EXPECT'; 2710 3291 EXPECT 2711 3292 $expected =~ s/\n$//s; 2712 3293 $this->assert_str_equals( $expected, $result ); 2713 } 2714 2715 sub verify_paging_with_limit_way_too_far { 3294 3295 return; 3296 } 3297 3298 sub test_paging_with_limit_way_too_far { 2716 3299 my $this = shift; 2717 3300 … … 2732 3315 ); 2733 3316 2734 my $expected = << EXPECT;3317 my $expected = <<'EXPECT'; 2735 3318 EXPECT 2736 3319 $expected =~ s/\n$//s; 2737 3320 $this->assert_str_equals( $expected, $result ); 3321 3322 return; 2738 3323 } 2739 3324 … … 2745 3330 #TODO: this is how the code has always worked, as the rendering of SEARCH results is done per web 2746 3331 #http://foswiki.org/Development/MakeSEARCHResultPartitioningByWebOptional 2747 sub verify_groupby_none_using_subwebs {3332 sub test_groupby_none_using_subwebs { 2748 3333 my $this = shift; 2749 3334 … … 2751 3336 Foswiki::Meta->new( $this->{session}, "$this->{test_web}/A" ); 2752 3337 $webObject->populateNewWeb(); 2753 my $topicObject = 2754 Foswiki::Meta->new( $this->{session}, "$this->{test_web}/A", 'TheTopic', 2755 <<CRUD); 3338 $webObject->finish(); 3339 my ($topicObject) = 3340 Foswiki::Func::readTopic( "$this->{test_web}/A", 'TheTopic' ); 3341 $topicObject->text( <<'CRUD'); 2756 3342 %META:FORM{name="TestForm"}% 2757 3343 %META:FIELD{name="Order" title="Order" value="3"}% 2758 3344 CRUD 2759 3345 $topicObject->save( forcedate => 1000 ); 3346 $topicObject->finish(); 2760 3347 2761 3348 $webObject = Foswiki::Meta->new( $this->{session}, "$this->{test_web}/B" ); 2762 3349 $webObject->populateNewWeb(); 2763 $topicObject = 2764 Foswiki::Meta->new( $this->{session}, "$this->{test_web}/B", 'TheTopic', 2765 <<CRUD); 3350 $webObject->finish(); 3351 ($topicObject) = 3352 Foswiki::Func::readTopic( "$this->{test_web}/B", 'TheTopic' ); 3353 $topicObject->text( <<'CRUD'); 2766 3354 %META:FORM{name="TestForm"}% 2767 3355 %META:FIELD{name="Order" title="Order" value="1"}% 2768 3356 CRUD 2769 3357 $topicObject->save( forcedate => 100 ); 3358 $topicObject->finish(); 2770 3359 2771 3360 $webObject = Foswiki::Meta->new( $this->{session}, "$this->{test_web}/C" ); 2772 3361 $webObject->populateNewWeb(); 2773 $topicObject = 2774 Foswiki::Meta->new( $this->{session}, "$this->{test_web}/C", 'TheTopic', 2775 <<CRUD); 3362 $webObject->finish(); 3363 ($topicObject) = 3364 Foswiki::Func::readTopic( "$this->{test_web}/C", 'TheTopic' ); 3365 $topicObject->text( <<'CRUD'); 2776 3366 %META:FORM{name="TestForm"}% 2777 3367 %META:FIELD{name="Order" title="Order" value="2"}% 2778 3368 CRUD 2779 3369 $topicObject->save( forcedate => 500 ); 3370 $topicObject->finish(); 3371 my $result; 2780 3372 2781 3373 #order by formfield, with groupby=none 2782 my $result = $this->{test_topicObject}->expandMacros( <<GNURF);3374 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2783 3375 %SEARCH{"Order!=''" 2784 3376 type="query" … … 2798 3390 2799 3391 #order by modified date, reverse=off, with groupby=none 2800 $result = $this->{test_topicObject}->expandMacros( << GNURF);3392 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2801 3393 %SEARCH{"Order!=''" 2802 3394 type="query" … … 2818 3410 2819 3411 #order by modified date, reverse=n, with groupby=none 2820 $result = $this->{test_topicObject}->expandMacros( << GNURF);3412 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2821 3413 %SEARCH{"Order!=''" 2822 3414 type="query" … … 2839 3431 #and the same again, this time using header&footer, as that is what really shows the issue. 2840 3432 #order by formfield, with groupby=none 2841 $result = $this->{test_topicObject}->expandMacros( << GNURF);3433 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2842 3434 %SEARCH{"Order!=''" 2843 3435 type="query" … … 2860 3452 2861 3453 #order by modified date, reverse=off, with groupby=none 2862 $result = $this->{test_topicObject}->expandMacros( << GNURF);3454 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2863 3455 %SEARCH{"Order!=''" 2864 3456 type="query" … … 2882 3474 2883 3475 #order by modified date, reverse=n, with groupby=none 2884 $result = $this->{test_topicObject}->expandMacros( << GNURF);3476 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2885 3477 %SEARCH{"Order!=''" 2886 3478 type="query" … … 2908 3500 my %testWebs = ( Main => 0, System => 10, Sandbox => 100 ); 2909 3501 while ( my ( $web, $delay ) = each %testWebs ) { 2910 my $topicObject =2911 Foswiki::Meta->new( $this->{session}, "$web", 'TheTopic',<<'CRUD');3502 my ($ltopicObject) = Foswiki::Func::readTopic( "$web", 'TheTopic' ); 3503 $ltopicObject->text(<<'CRUD'); 2912 3504 Just some dummy search topic. 2913 3505 CRUD 2914 $topicObject->save( forcedate => $delay ); 3506 $ltopicObject->save( forcedate => $delay ); 3507 $ltopicObject->finish(); 2915 3508 } 2916 3509 2917 $result = $this->{test_topicObject}->expandMacros( << GNURF);3510 $result = $this->{test_topicObject}->expandMacros( <<"GNURF" ); 2918 3511 %SEARCH{"1" 2919 3512 type="query" … … 2933 3526 $this->assert_equals( "HEADERSystem TheTopic, Sandbox TheTopicFOOTER\n", 2934 3527 $result ); 3528 3529 return; 2935 3530 } 2936 3531 … … 2948 3543 } 2949 3544 2950 sub verify_no_format_no_shit {3545 sub test_no_format_no_shit { 2951 3546 my $this = shift; 2952 3547 2953 3548 my $result = $this->{test_topicObject}->expandMacros('%SEARCH{"BLEEGLE"}%'); 2954 $this->assert_html_equals( << 'CRUD', _cut_the_crap($result) );2955 Searched: <noautolink>BLEEGLE</noautolink>Results from <nop> TemporarySEARCHTestWebSEARCHweb retrieved at TIME3549 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3550 Searched: <noautolink>BLEEGLE</noautolink>Results from <nop>$this->{test_web} web retrieved at TIME 2956 3551 2957 3552 <a href="">OkATopic</a> … … 2977 3572 my $session = $this->{session}; 2978 3573 if ( !$session->topicExists( 'TemporarySEARCHUsersWeb', 'WikiGuest' ) ) { 2979 my $userTopic = Foswiki::Meta->new( 2980 $session, 'TemporarySEARCHUsersWeb', 2981 'WikiGuest', 'Just this poor old WikiGuest' 2982 ); 3574 my ($userTopic) = 3575 Foswiki::Func::readTopic( 'TemporarySEARCHUsersWeb', 'WikiGuest' ); 3576 $userTopic->text('Just this poor old WikiGuest'); 2983 3577 $userTopic->save(); 3578 $userTopic->finish(); 2984 3579 } 2985 3580 $this->assert( … … 2991 3586 $this->{test_topicObject} 2992 3587 ->expandMacros('%SEARCH{"BLEEGLE" nosummary="on"}%'); 2993 $this->assert_html_equals( << CRUD, _cut_the_crap($result) );2994 Searched: <noautolink>BLEEGLE</noautolink>Results from <nop> TemporarySEARCHTestWebSEARCHweb retrieved at TIME3588 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3589 Searched: <noautolink>BLEEGLE</noautolink>Results from <nop>$this->{test_web} web retrieved at TIME 2995 3590 2996 3591 <a href="">OkATopic</a> … … 3011 3606 $this->{test_topicObject} 3012 3607 ->expandMacros('%SEARCH{"BLEEGLE" nosearch="on"}%'); 3013 $this->assert_html_equals( << CRUD, _cut_the_crap($result) );3014 Results from <nop> TemporarySEARCHTestWebSEARCHweb retrieved at TIME3608 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3609 Results from <nop>$this->{test_web} web retrieved at TIME 3015 3610 3016 3611 <a href="">OkATopic</a> … … 3036 3631 $this->{test_topicObject} 3037 3632 ->expandMacros('%SEARCH{"BLEEGLE" nototal="on"}%'); 3038 $this->assert_html_equals( << CRUD, _cut_the_crap($result) );3633 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3039 3634 Searched: <noautolink>BLEEGLE</noautolink> 3040 Results from <nop> TemporarySEARCHTestWebSEARCHweb retrieved at TIME3635 Results from <nop>$this->{test_web} web retrieved at TIME 3041 3636 3042 3637 <a href="">OkATopic</a> … … 3062 3657 $this->{test_topicObject} 3063 3658 ->expandMacros('%SEARCH{"BLEEGLE" noheader="on"}%'); 3064 $this->assert_html_equals( << CRUD, _cut_the_crap($result) );3659 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3065 3660 Searched: <noautolink>BLEEGLE</noautolink> 3066 3661 <a href="">OkATopic</a> … … 3085 3680 $this->{test_topicObject} 3086 3681 ->expandMacros('%SEARCH{"BLEEGLE" noempty="on"}%'); 3087 $this->assert_html_equals( << CRUD, _cut_the_crap($result) );3682 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3088 3683 Searched: <noautolink>BLEEGLE</noautolink> 3089 Results from <nop> TemporarySEARCHTestWebSEARCHweb retrieved at TIME3684 Results from <nop>$this->{test_web} web retrieved at TIME 3090 3685 3091 3686 … … 3113 3708 $this->{test_topicObject} 3114 3709 ->expandMacros('%SEARCH{"BLEEGLE" zeroresults="on"}%'); 3115 $this->assert_html_equals( << CRUD, _cut_the_crap($result) );3710 $this->assert_html_equals( <<"CRUD", _cut_the_crap($result) ); 3116 3711 Searched: <noautolink>BLEEGLE</noautolink> 3117 Results from <nop> TemporarySEARCHTestWebSEARCHweb retrieved at TIME3712 Results from <nop>$this->{test_web} web retrieved at TIME 3118 3713 3119 3714 … … 3147 3742 ->expandMacros('%SEARCH{"BLEEGLE" nosummary="on" nonoise="on"}%'); 3148 3743 $this->assert_html_equals( $result, $result2 ); 3744 3745 return; 3149 3746 } 3150 3747 … … 3211 3808 my $not_quote_dontcount = $#list; 3212 3809 $this->assert( $not_quote_dontcount == 4 ); 3810 3811 return; 3213 3812 } 3214 3813 … … 3275 3874 my $not_quote_dontcount = $#list; 3276 3875 $this->assert( $not_quote_dontcount == 4 ); 3876 3877 return; 3277 3878 } 3278 3879 … … 3336 3937 my $not_quote_dontcount = $#list; 3337 3938 $this->assert( $not_quote_dontcount == 4 ); 3939 3940 return; 3338 3941 } 3339 3942 … … 3397 4000 my $not_quote_dontcount = $#list; 3398 4001 $this->assert( $not_quote_dontcount == 4 ); 4002 4003 return; 3399 4004 } 3400 4005 … … 3409 4014 my $TEST_TEXT = "xxx Shamira"; 3410 4015 my $TEST_TOPIC = 'StopWordTestTopic'; 3411 my $topicObject=3412 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, $TEST_TOPIC,3413 $TEST_TEXT);4016 my ($topicObject) = 4017 Foswiki::Func::readTopic( $this->{test_web}, $TEST_TOPIC ); 4018 $topicObject->text($TEST_TEXT); 3414 4019 $topicObject->save(); 4020 $topicObject->finish(); 3415 4021 3416 4022 my $result = … … 3440 4046 3441 4047 Foswiki::Func::setPreferencesValue( 'SEARCHSTOPWORDS', $origSetting ); 4048 4049 return; 3442 4050 } 3443 4051 … … 3458 4066 Alan says: 'Oh yes; I knew I'd seen them somewhere before! But how do I know I won't go mad and do something to you? I just thought of something, just then.' Alan is now very agitated. 'It makes my blood boil the way analysts never defend themselves when they are attacked in the press. You hear one slander after another about Freud and psychoanalysis, and what do your lot do? Nothing!'"; 3459 4067 3460 my $topicObject=3461 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, $topicName,3462 $TEST_SUMMARY_TEXT);4068 my ($topicObject) = 4069 Foswiki::Func::readTopic( $this->{test_web}, $topicName ); 4070 $topicObject->text($TEST_SUMMARY_TEXT); 3463 4071 $topicObject->save(); 4072 $topicObject->finish(); 4073 4074 return; 3464 4075 } 3465 4076 … … 3470 4081 =cut 3471 4082 3472 sub verify_summary_default_word_search {4083 sub test_summary_default_word_search { 3473 4084 my $this = shift; 3474 4085 … … 3480 4091 ); 3481 4092 3482 $this->assert_html_equals( << CRUD, $result );4093 $this->assert_html_equals( <<'CRUD', $result ); 3483 4094 Alan says<nop>: 'I was on a landing; there were banisters'. He pauses before describing the exact shape and details of the banisters. 'There was a thin man there. I was ... 3484 4095 CRUD 4096 4097 return; 3485 4098 } 3486 4099 … … 3491 4104 =cut 3492 4105 3493 sub verify_summary_short_word_search {4106 sub test_summary_short_word_search { 3494 4107 my $this = shift; 3495 4108 … … 3501 4114 ); 3502 4115 3503 $this->assert_html_equals( << CRUD, $result );4116 $this->assert_html_equals( <<'CRUD', $result ); 3504 4117 Alan says<nop>: 'I was ... 3505 4118 CRUD 4119 4120 return; 3506 4121 } 3507 4122 … … 3512 4127 =cut 3513 4128 3514 sub verify_summary_searchcontext_default_word_search {4129 sub test_summary_searchcontext_default_word_search { 3515 4130 my $this = shift; 3516 4131 … … 3522 4137 ); 3523 4138 3524 $this->assert_html_equals( << CRUD, $result );4139 $this->assert_html_equals( <<'CRUD', $result ); 3525 4140 <b>…</b> his analysis and his need to <em>do</em> it very carefully. He knows <b>…</b> somewhere before! But how <em>do</em> I know I won't go mad and do <b>…</b> and psychoanalysis, and what <em>do</em> your lot do? Nothing <b>…</b> 3526 4141 CRUD 4142 4143 return; 3527 4144 } 3528 4145 … … 3533 4150 =cut 3534 4151 3535 sub verify_summary_searchcontext_short_word_search {4152 sub test_summary_searchcontext_short_word_search { 3536 4153 my $this = shift; 3537 4154 … … 3543 4160 ); 3544 4161 3545 $this->assert_html_equals( << CRUD, $result );4162 $this->assert_html_equals( <<'CRUD', $result ); 3546 4163 <b>…</b> topple over too; might lose <em>his</em> balance. As Alan thought <b>…</b> 3547 4164 CRUD 4165 4166 return; 3548 4167 } 3549 4168 … … 3554 4173 =cut 3555 4174 3556 sub verify_summary_searchcontext_long_word_search {4175 sub test_summary_searchcontext_long_word_search { 3557 4176 my $this = shift; 3558 4177 … … 3564 4183 ); 3565 4184 3566 $this->assert_html_equals( << CRUD, $result );4185 $this->assert_html_equals( <<'CRUD', $result ); 3567 4186 <b>…</b> topple over too; might lose <em>his</em> balance. As Alan thought <b>…</b> about different parts of <em>his</em> dream he let his mind follow <b>…</b> came to him. He thought about <em>his</em> weight loss programme. He <b>…</b> later. Perhaps it's because <em>his</em> next goal is 18 stone, he <b>…</b> 3568 4187 CRUD 4188 4189 return; 3569 4190 } 3570 4191 … … 3574 4195 3575 4196 $result = $this->{test_topicObject}->expandMacros('%SEARCH{"NOBLEEGLE"}%'); 3576 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4197 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3577 4198 Searched: <noautolink>NOBLEEGLE</noautolink> 3578 4199 Number of topics: 0 … … 3582 4203 $this->{test_topicObject} 3583 4204 ->expandMacros('%SEARCH{"NOBLEEGLE" zeroresults="on"}%'); 3584 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4205 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3585 4206 Searched: <noautolink>NOBLEEGLE</noautolink> 3586 4207 Number of topics: 0 … … 3615 4236 $this->{test_topicObject}->expandMacros( 3616 4237 '%SEARCH{"NOBLEEGLE" zeroresults="I did not find anything."}%'); 3617 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4238 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3618 4239 I did not find anything. 3619 4240 RESULT … … 3623 4244 $this->{test_topicObject} 3624 4245 ->expandMacros('%SEARCH{"NOBLEEGLE" nototal="on"}%'); 3625 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4246 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3626 4247 Searched: <noautolink>NOBLEEGLE</noautolink> 3627 4248 RESULT … … 3630 4251 $this->{test_topicObject} 3631 4252 ->expandMacros('%SEARCH{"NOBLEEGLE" nototal="on" zeroresults="on"}%'); 3632 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4253 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3633 4254 Searched: <noautolink>NOBLEEGLE</noautolink> 3634 4255 RESULT … … 3643 4264 '%SEARCH{"NOBLEEGLE" nototal="on" zeroresults="I did not find anything."}%' 3644 4265 ); 3645 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4266 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3646 4267 I did not find anything. 3647 4268 RESULT … … 3651 4272 $this->{test_topicObject} 3652 4273 ->expandMacros('%SEARCH{"NOBLEEGLE" nototal="off"}%'); 3653 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4274 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3654 4275 Searched: <noautolink>NOBLEEGLE</noautolink> 3655 4276 Number of topics: 0 … … 3659 4280 $this->{test_topicObject} 3660 4281 ->expandMacros('%SEARCH{"NOBLEEGLE" nototal="off" zeroresults="on"}%'); 3661 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4282 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3662 4283 Searched: <noautolink>NOBLEEGLE</noautolink> 3663 4284 Number of topics: 0 … … 3673 4294 '%SEARCH{"NOBLEEGLE" nototal="off" zeroresults="I did not find anything."}%' 3674 4295 ); 3675 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4296 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3676 4297 I did not find anything. 3677 4298 RESULT 4299 4300 return; 3678 4301 } 3679 4302 … … 3682 4305 my $this = shift; 3683 4306 3684 my $text = << HERE;4307 my $text = <<'HERE'; 3685 4308 %META:TOPICINFO{author="TopicUserMapping_guest" date="1" format="1.1" version="1.2"}% 3686 4309 ---+ Progressive Sexuality … … 3688 4311 3689 4312 HERE 3690 my $topicObject=3691 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, "VeryOldTopic",3692 $text);4313 my ($topicObject) = 4314 Foswiki::Func::readTopic( $this->{test_web}, "VeryOldTopic" ); 4315 $topicObject->text($text); 3693 4316 my $rev = $topicObject->save( forcedate => 86420 ); # > 86400, see Item10389 3694 4317 $this->assert_num_equals( 1, $rev ); 4318 $topicObject->finish(); 3695 4319 3696 4320 #TODO: sadly, the core Handlers don't set the filedate … … 3708 4332 '%SEARCH{"1" type="query" date="1970" nonoise="on" format="$topic"}%'); 3709 4333 3710 $this->assert_html_equals( << RESULT, _cut_the_crap($result) );4334 $this->assert_html_equals( <<'RESULT', _cut_the_crap($result) ); 3711 4335 VeryOldTopic 3712 4336 RESULT 4337 4338 return; 3713 4339 } 3714 4340 3715 4341 sub verify_nl_in_result { 3716 4342 my $this = shift; 3717 my $text = <<HERE; 3718 %META:TOPICINFO{author="TopicUserMapping_guest" date="1" format="1.1" version="1.2"}% 4343 my $text = <<'HERE'; 3719 4344 Radical Meta-Physics 3720 4345 Marxism … … 3724 4349 %META:FIELD{name="Name" attributes="" title="Name" value="Meta-Physics%0aMarxism%0aCrime%0aSuicide%0aPaganism."}% 3725 4350 HERE 3726 my $topicObject=3727 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, "OffColour",3728 $text);4351 my ($topicObject) = 4352 Foswiki::Func::readTopic( $this->{test_web}, "OffColour" ); 4353 $topicObject->text($text); 3729 4354 $topicObject->save(); 4355 $topicObject->finish(); 3730 4356 3731 4357 my $result; … … 3737 4363 '%SEARCH{"OffColour" scope="topic" nonoise="on" format="$formfield(Name)"}%' 3738 4364 ); 3739 $this->assert_str_equals( << RESULT, "$result\n" );4365 $this->assert_str_equals( <<'RESULT', "$result\n" ); 3740 4366 Meta-Physics<br />Marxism<br />Crime<br />Suicide<br />Paganism. 3741 4367 RESULT … … 3746 4372 '%SEARCH{"OffColour" scope="topic" nonoise="on" format="$pattern(.*?(Meta.*?Paganism).*)"}%' 3747 4373 ); 3748 $this->assert_str_equals( << RESULT, "$result\n" );4374 $this->assert_str_equals( <<'RESULT', "$result\n" ); 3749 4375 Meta-Physics 3750 4376 Marxism … … 3759 4385 '%SEARCH{"OffColour" scope="topic" nonoise="on" format="$pattern(.*?(Meta.*?Paganism).*)" newline="X"}%' 3760 4386 ); 3761 $this->assert_str_equals( << RESULT, "$result\n" );4387 $this->assert_str_equals( <<'RESULT', "$result\n" ); 3762 4388 Meta-PhysicsXMarxismXCrimeXSuicideXPaganism 3763 4389 RESULT … … 3772 4398 #Meta-PhysicsXMarxismXCrimeXSuicideXPaganism. 3773 4399 #RESULT 4400 4401 return; 3774 4402 } 3775 4403 3776 4404 ########################################### 3777 4405 #pager formatting 3778 sub verify_pager_on {4406 sub test_pager_on { 3779 4407 my $this = shift; 3780 4408 … … 3799 4427 ); 3800 4428 3801 my $expected = <<EXPECT; 4429 my $expected = $this->_expect_with_deps( 4430 <<"FOSWIKI12", 4431 Main.WebChanges 4432 Main.WebHome 4433 Main.WebIndex 4434 Main.WebPreferences 4435 FOOT(4,4)Sandbox.WebChanges 4436 FOOT(1,1)<div class="foswikiSearchResultsPager"> 4437 Page 1 of 3 [[$viewTopicUrl?SEARCHc6139cf1d63c9614230f742fca2c6a36=2][Next >]] 4438 </div> 4439 FOSWIKI12 4440 'Foswiki,<,1.2' => <<"FOSWIKI11"); 3802 4441 System.WebChanges 3803 4442 System.WebHome … … 3808 4447 Page 1 of 3 [[$viewTopicUrl?SEARCHc6139cf1d63c9614230f742fca2c6a36=2][Next >]] 3809 4448 </div> 3810 EXPECT 4449 FOSWIKI11 3811 4450 $expected =~ s/\n$//s; 3812 4451 $this->assert_str_equals( $expected, $result ); … … 3828 4467 ); 3829 4468 3830 $expected = <<EXPECT; 4469 $expected = $this->_expect_with_deps( 4470 <<"FOSWIKI12", 4471 Sandbox.WebHome 4472 Sandbox.WebIndex 4473 Sandbox.WebPreferences 4474 FOOT(3,3)System.WebChanges 4475 System.WebHome 4476 FOOT(2,2)<div class="foswikiSearchResultsPager"> 4477 [[$viewTopicUrl?SEARCH6331ae02a320baf1478c8302e38b7577=1][< Previous]] Page 2 of 3 [[$viewTopicUrl?SEARCH6331ae02a320baf1478c8302e38b7577=3][Next >]] 4478 </div> 4479 FOSWIKI12 4480 'Foswiki,<,1.2' => <<"FOSWIKI11"); 3831 4481 Main.WebHome 3832 4482 Main.WebIndex … … 3837 4487 [[$viewTopicUrl?SEARCH6331ae02a320baf1478c8302e38b7577=1][< Previous]] Page 2 of 3 [[$viewTopicUrl?SEARCH6331ae02a320baf1478c8302e38b7577=3][Next >]] 3838 4488 </div> 3839 EXPECT 4489 FOSWIKI11 3840 4490 $expected =~ s/\n$//s; 3841 4491 $this->assert_str_equals( $expected, $result ); 3842 } 3843 3844 sub verify_pager_on_pagerformat { 4492 4493 return; 4494 } 4495 4496 sub test_pager_on_pagerformat { 3845 4497 my $this = shift; 3846 4498 … … 3849 4501 $this->{test_topicObject}->topic, 'view' ); 3850 4502 3851 my $result = $this->{test_topicObject}->expandMacros( 3852 '%SEARCH{4503 my $result = $this->{test_topicObject}->expandMacros(<<'EXPECT'); 4504 %SEARCH{ 3853 4505 "web" 3854 4506 type="text" … … 3864 4516 pagerformat="$n..prev=$previouspage, $currentpage, next=$nextpage, numberofpages=$numberofpages, pagesize=$pagesize, prevurl=$previousurl, nexturl=$nexturl..$n" 3865 4517 }% 3866 ' 3867 ); 3868 3869 my $expected = <<EXPECT; 4518 EXPECT 4519 4520 my $expected = $this->_expect_with_deps( 4521 <<"FOSWIKI12", 4522 Main.WebChanges 4523 Main.WebHome 4524 Main.WebIndex 4525 Main.WebPreferences 4526 FOOT(4,4)Sandbox.WebChanges 4527 FOOT(1,1) 4528 ..prev=0, 1, next=2, numberofpages=3, pagesize=5, prevurl=, nexturl=$viewTopicUrl?SEARCHe9863b5d7ec27abeb8421578b0747c25=2.. 4529 FOSWIKI12 4530 'Foswiki,<,1.2' => <<"FOSWIKI11"); 3870 4531 System.WebChanges 3871 4532 System.WebHome … … 3875 4536 FOOT(1,1) 3876 4537 ..prev=0, 1, next=2, numberofpages=3, pagesize=5, prevurl=, nexturl=$viewTopicUrl?SEARCHe9863b5d7ec27abeb8421578b0747c25=2.. 3877 EXPECT 4538 FOSWIKI11 3878 4539 $this->assert_str_equals( $expected, $result ); 3879 4540 … … 3896 4557 ); 3897 4558 3898 $expected = <<EXPECT; 4559 $expected = $this->_expect_with_deps( 4560 <<"FOSWIKI12", 4561 Sandbox.WebHome 4562 Sandbox.WebIndex 4563 Sandbox.WebPreferences 4564 FOOT(3,3)System.WebChanges 4565 System.WebHome 4566 FOOT(2,2) 4567 ..prev=1, 2, next=3, numberofpages=3, pagesize=5, prevurl=$viewTopicUrl?SEARCHc5ceccfcec96473a9efe986cf3597eb1=1, nexturl=$viewTopicUrl?SEARCHc5ceccfcec96473a9efe986cf3597eb1=3.. 4568 FOSWIKI12 4569 'Foswiki,<,1.2' => <<"FOSWIKI11"); 3899 4570 Main.WebHome 3900 4571 Main.WebIndex … … 3904 4575 FOOT(2,2) 3905 4576 ..prev=1, 2, next=3, numberofpages=3, pagesize=5, prevurl=$viewTopicUrl?SEARCHc5ceccfcec96473a9efe986cf3597eb1=1, nexturl=$viewTopicUrl?SEARCHc5ceccfcec96473a9efe986cf3597eb1=3.. 3906 EXPECT 4577 FOSWIKI11 3907 4578 $this->assert_str_equals( $expected, $result ); 3908 } 3909 3910 sub verify_pager_off_pagerformat { 4579 4580 return; 4581 } 4582 4583 sub test_pager_off_pagerformat { 3911 4584 my $this = shift; 3912 4585 … … 3932 4605 ); 3933 4606 3934 my $expected = <<EXPECT; 4607 my $expected = $this->_expect_with_deps( 4608 <<'FOSWIKI12', 4609 Main.WebChanges 4610 Main.WebHome 4611 Main.WebIndex 4612 Main.WebPreferences 4613 FOOT(4,4)Sandbox.WebChanges 4614 FOOT(1,1) 4615 FOSWIKI12 4616 'Foswiki,<,1.2' => <<'FOSWIKI11'); 3935 4617 System.WebChanges 3936 4618 System.WebHome … … 3939 4621 FOOT(4,4)Main.WebChanges 3940 4622 FOOT(1,1) 3941 EXPECT 4623 FOSWIKI11 3942 4624 $expected =~ s/\n$//s; 3943 4625 $this->assert_str_equals( $expected, $result ); … … 3960 4642 ); 3961 4643 3962 $expected = <<EXPECT; 4644 $expected = $this->_expect_with_deps( 4645 <<'FOSWIKI12', 4646 Sandbox.WebHome 4647 Sandbox.WebIndex 4648 Sandbox.WebPreferences 4649 FOOT(3,3)System.WebChanges 4650 System.WebHome 4651 FOOT(2,2) 4652 FOSWIKI12 4653 'Foswiki,<,1.2' => <<'FOSWIKI11'); 3963 4654 Main.WebHome 3964 4655 Main.WebIndex … … 3967 4658 Sandbox.WebHome 3968 4659 FOOT(2,2) 3969 EXPECT 4660 FOSWIKI11 3970 4661 $expected =~ s/\n$//s; 3971 4662 $this->assert_str_equals( $expected, $result ); 3972 } 3973 3974 sub verify_pager_off_pagerformat_pagerinheaderfooter { 4663 4664 return; 4665 } 4666 4667 sub test_pager_off_pagerformat_pagerinheaderfooter { 3975 4668 my $this = shift; 3976 4669 … … 3997 4690 ); 3998 4691 3999 my $expected = <<EXPECT; 4692 my $expected = $this->_expect_with_deps( 4693 <<'FOSWIKI12', 4694 HEADER(..prev=0, 1, next=2, numberofpages=3, pagesize=5..) 4695 Main.WebChanges 4696 Main.WebHome 4697 Main.WebIndex 4698 Main.WebPreferences 4699 FOOT(4,4)(..prev=0, 1, next=2, numberofpages=3, pagesize=5..)HEADER(..prev=0, 1, next=2, numberofpages=3, pagesize=5..) 4700 Sandbox.WebChanges 4701 FOOT(1,1)(..prev=0, 1, next=2, numberofpages=3, pagesize=5..) 4702 FOSWIKI12 4703 'Foswiki,<,1.2' => <<'FOSWIKI11'); 4000 4704 HEADER(..prev=0, 1, next=2, numberofpages=3, pagesize=5..) 4001 4705 System.WebChanges … … 4006 4710 Main.WebChanges 4007 4711 FOOT(1,1)(..prev=0, 1, next=2, numberofpages=3, pagesize=5..) 4008 EXPECT 4712 FOSWIKI11 4009 4713 $expected =~ s/\n$//s; 4010 4714 $this->assert_str_equals( $expected, $result ); … … 4028 4732 ); 4029 4733 4030 $expected = <<EXPECT; 4734 $expected = $this->_expect_with_deps( 4735 <<'FOSWIKI12', 4736 HEADER(..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4737 Sandbox.WebHome 4738 Sandbox.WebIndex 4739 Sandbox.WebPreferences 4740 FOOT(3,3)(..prev=1, 2, next=3, numberofpages=3, pagesize=5..)HEADER(..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4741 System.WebChanges 4742 System.WebHome 4743 FOOT(2,2)(..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4744 FOSWIKI12 4745 'Foswiki,<,1.2' => <<'FOSWIKI11'); 4031 4746 HEADER(..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4032 4747 Main.WebHome … … 4037 4752 Sandbox.WebHome 4038 4753 FOOT(2,2)(..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4039 EXPECT 4754 FOSWIKI11 4040 4755 $expected =~ s/\n$//s; 4041 4756 $this->assert_str_equals( $expected, $result ); 4757 4758 return; 4042 4759 } 4043 4760 … … 4063 4780 ); 4064 4781 4065 my $expected = <<EXPECT; 4782 my $expected = $this->_expect_with_deps( 4783 <<'FOSWIKI12', 4784 HEADER(ntopics=0..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=0 4785 Sandbox.WebHome (ntopics=1..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=1 4786 Sandbox.WebIndex (ntopics=2..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=2 4787 Sandbox.WebPreferences (ntopics=3..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=3 4788 FOOT(3,3)(ntopics=3..prev=1, 2, next=3, numberofpages=3, pagesize=5..)HEADER(ntopics=0..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=0 4789 System.WebChanges (ntopics=1..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=1 4790 System.WebHome (ntopics=2..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=2 4791 FOOT(2,2)(ntopics=2..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4792 FOSWIKI12 4793 'Foswiki,<,1.2' => <<'FOSWIKI11'); 4066 4794 HEADER(ntopics=0..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=0 4067 4795 Main.WebHome (ntopics=1..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=1 … … 4072 4800 Sandbox.WebHome (ntopics=2..prev=1, 2, next=3, numberofpages=3, pagesize=5..)ntopics=2 4073 4801 FOOT(2,2)(ntopics=2..prev=1, 2, next=3, numberofpages=3, pagesize=5..) 4074 EXPECT 4802 FOSWIKI11 4803 4075 4804 $expected =~ s/\n$//s; 4076 4805 $this->assert_str_equals( $expected, $result ); 4077 4806 4078 } 4079 4080 sub verify_simple_format { 4807 return; 4808 } 4809 4810 sub test_simple_format { 4081 4811 my $this = shift; 4082 4812 … … 4092 4822 ' 4093 4823 ); 4094 my $expected = <<'HERE'; 4824 my $expected = $this->_expect_with_deps( 4825 <<'FOSWIKI12', 4826 * !Main.WebHome 4827 * !Main.WebPreferences 4828 * !Main.WebTopicList 4829 <div class="foswikiSearchResultCount">Number of topics: <span>3</span></div> 4830 * !Sandbox.WebHome 4831 * !Sandbox.WebPreferences 4832 * !Sandbox.WebTopicList 4833 <div class="foswikiSearchResultCount">Number of topics: <span>3</span></div> 4834 * !System.WebHome 4835 * !System.WebPreferences 4836 * !System.WebTopicList 4837 <div class="foswikiSearchResultCount">Number of topics: <span>3</span></div> 4838 * !TestCases.WebHome 4839 * !TestCases.WebPreferences 4840 * !TestCases.WebTopicList 4841 <div class="foswikiSearchResultCount">Number of topics: <span>3</span></div> 4842 FOSWIKI12 4843 'Foswiki,<,1.2' => <<'FOSWIKI11'); 4095 4844 * !TestCases.WebHome 4096 4845 * !TestCases.WebPreferences … … 4109 4858 * !Sandbox.WebTopicList 4110 4859 <div class="foswikiSearchResultCount">Number of topics: <span>3</span></div> 4111 HERE 4860 FOSWIKI11 4112 4861 4113 4862 $this->assert_str_equals( $expected, $actual ); 4114 } 4115 4116 sub verify_formatdotBang { 4863 4864 return; 4865 } 4866 4867 sub test_formatdotBang { 4117 4868 my $this = shift; 4118 4869 … … 4136 4887 4137 4888 $this->assert_str_equals( $expected, $actual ); 4138 } 4139 4140 sub verify_delayed_expansion { 4141 my $this = shift; 4142 eval "require Foswiki::Macros::SEARCH"; 4889 4890 return; 4891 } 4892 4893 sub test_delayed_expansion { 4894 my $this = shift; 4895 $this->assert( eval { require Foswiki::Macros::SEARCH; 1; } 4896 and not $EVAL_ERROR ); 4143 4897 4144 4898 my $result = $Foswiki::Plugins::SESSION->SEARCH( … … 4154 4908 $this->{test_topicObject} 4155 4909 ); 4156 $this->assert_str_equals( << EXPECT, $result . "\n" );4910 $this->assert_str_equals( <<'EXPECT', $result . "\n" ); 4157 4911 WebHome, WebIndex, WebPreferences, WebHome, WebIndex, WebPreferences 4158 4912 EXPECT … … 4170 4924 $this->{test_topicObject} 4171 4925 ); 4172 $this->assert_str_equals( << EXPECT, $result . "\n" );4926 $this->assert_str_equals( <<'EXPECT', $result . "\n" ); 4173 4927 %WIKINAME%, %WIKINAME%, %WIKINAME%, %WIKINAME%, %WIKINAME%, %WIKINAME% 4174 4928 EXPECT … … 4189 4943 $this->{test_topicObject} 4190 4944 ); 4191 $this->assert_str_equals( << EXPECT, $result . "\n" );4945 $this->assert_str_equals( <<'EXPECT', $result . "\n" ); 4192 4946 %INCLUDE{Main.WebHeader}%WebHome, WebIndex, WebPreferences%INCLUDE{Main.WebFooter}%%INCLUDE{Main.WebHeader}%WebHome, WebIndex, WebPreferences%INCLUDE{Main.WebFooter}% 4193 4947 EXPECT 4194 4948 4949 return; 4195 4950 } 4196 4951 … … 4221 4976 # $this->{twiki}->{store}->saveTopic( 'simon', 4222 4977 # $this->{test_web}, 'QueryTopic', $text, undef, {forcedate=>1178612772} ); 4223 my $topicObject = 4224 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'QueryTopic', 4225 $text ); 4226 $topicObject->save( forcedate => 1178612772, author => 'simon' ); 4978 my ($topicObject) = 4979 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopic' ); 4980 $topicObject->text($text); 4981 $topicObject->save( 4982 forcedate => 1178412772, 4983 author => 'admin', 4984 forcenewrevision => 1 4985 ); 4986 $topicObject->save( 4987 forcedate => 1178612772, 4988 author => 'simon', 4989 forcenewrevision => 1 4990 ); 4991 $topicObject->finish(); 4227 4992 4228 4993 $text = <<'HERE'; 4229 %META:TOPICINFO{author="BaseUserMapping_666" date="1 2" format="1.1" version="1.2"}%4994 %META:TOPICINFO{author="BaseUserMapping_666" date="1108412772" format="1.1" version="1.2"}% 4230 4995 first line 4231 4996 This is QueryTopicTwo SMONG … … 4247 5012 #$this->{twiki}->{store}->saveTopic( 'admin', 4248 5013 # $this->{test_web}, 'QueryTopicTwo', $text, undef, {forcedate=>12} ); 4249 $topicObject = 4250 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'QueryTopicTwo', 4251 $text ); 4252 $topicObject->save( forcedate => 12, author => 'admin' ); 5014 ($topicObject) = 5015 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicTwo' ); 5016 $topicObject->text($text); 5017 $topicObject->save( 5018 forcedate => 1108312772, 5019 author => 'admin', 5020 forcenewrevision => 1 5021 ); 5022 $topicObject->save( 5023 forcedate => 1178612772, 5024 author => 'simon', 5025 forcenewrevision => 1 5026 ); 5027 $topicObject->finish(); 4253 5028 4254 5029 $text = <<'HERE'; 4255 %META:TOPICINFO{author="TopicUserMapping_Gerald" date="1 4" format="1.1" version="1.2"}%5030 %META:TOPICINFO{author="TopicUserMapping_Gerald" date="1108412782" format="1.1" version="1.2"}% 4256 5031 first line 4257 5032 This is QueryTopicThree SMONG … … 4273 5048 #$this->{twiki}->{store}->saveTopic( 'Gerald', 4274 5049 # $this->{test_web}, 'QueryTopicThree', $text, undef, {forcedate=>14} ); 4275 $topicObject=4276 Foswiki:: Meta->new( $this->{session}, $this->{test_web},4277 'QueryTopicThree', $text);4278 $topicObject->save( forcedate => 1 4, author => 'Gerald' );4279 4280 $this->{session}->finish(); 4281 my $query = new Unit::Request("");5050 ($topicObject) = 5051 Foswiki::Func::readTopic( $this->{test_web}, 'QueryTopicThree' ); 5052 $topicObject->text($text); 5053 $topicObject->save( forcedate => 1108413782, author => 'Gerald' ); 5054 $topicObject->finish(); 5055 5056 my $query = Unit::Request->new(''); 4282 5057 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 4283 5058 4284 $this-> {session} = new Foswiki( undef, $query );5059 $this->createNewFoswikiSession( undef, $query ); 4285 5060 $this->assert_str_equals( $this->{test_web}, $this->{session}->{webName} ); 4286 $Foswiki::Plugins::SESSION = $this->{session}; 4287 4288 $this->{test_topicObject} = 4289 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 4290 $this->{test_topic} ); 4291 } 4292 4293 sub verify_orderTopic { 5061 5062 return; 5063 } 5064 5065 sub test_orderTopic { 4294 5066 my $this = shift; 4295 5067 … … 4324 5096 ); 4325 5097 4326 #order=created 4327 #TODO: looks like forcedate is broken? so the date tests are unlikely to have enough difference to order. 4328 $result = 4329 $this->{test_topicObject}->expandMacros( 4330 $search . 'order="created" format="$topic ($createdate)"}%' ); 4331 4332 #$this->assert_str_equals( "OkATopic,OkBTopic,OkTopic,QueryTopic,QueryTopicThree,QueryTopicTwo,TestTopicSEARCH,WebPreferences", $result ); 5098 #order=created 5099 $result = 5100 $this->{test_topicObject} 5101 ->expandMacros( $search . 'order="created" format="$topic"}%' ); 5102 5103 $this->assert_str_equals( 5104 "QueryTopicTwo,QueryTopicThree,QueryTopic,WebPreferences,TestTopicSEARCH,OkTopic,OkATopic,OkBTopic", 5105 $result 5106 ); 4333 5107 4334 5108 $result = … … 4336 5110 ->expandMacros( $search . 'order="created" reverse="on"}%' ); 4337 5111 4338 #$this->assert_str_equals( "WebPreferences,TestTopicSEARCH,QueryTopicTwo,QueryTopicThree,QueryTopic,OkTopic,OkBTopic,OkATopic", $result ); 5112 $this->assert_str_equals( 5113 "OkBTopic,OkATopic,OkTopic,TestTopicSEARCH,WebPreferences,QueryTopic,QueryTopicThree,QueryTopicTwo", 5114 $result 5115 ); 4339 5116 4340 5117 #order=modified … … 4342 5119 $this->{test_topicObject}->expandMacros( $search . 'order="modified"}%' ); 4343 5120 4344 #$this->assert_str_equals( "OkATopic,OkBTopic,OkTopic,QueryTopic,QueryTopicThree,QueryTopicTwo,TestTopicSEARCH,WebPreferences", $result ); 4345 4346 $result = 4347 $this->{test_topicObject} 4348 ->expandMacros( $search . 'order="modified" reverse="on"}%' ); 4349 4350 #$this->assert_str_equals( "WebPreferences,TestTopicSEARCH,QueryTopicTwo,QueryTopicThree,QueryTopic,OkTopic,OkBTopic,OkATopic", $result ); 5121 $this->assert_str_equals( 5122 "QueryTopicThree,QueryTopicTwo,QueryTopic,WebPreferences,TestTopicSEARCH,OkTopic,OkATopic,OkBTopic", 5123 $result 5124 ); 5125 5126 $result = 5127 $this->{test_topicObject}->expandMacros( 5128 $search . 'order="modified" reverse="on" format="$topic"}%' ); 5129 5130 #be very careful with this test and the one above - the change in order between QueryTopicTwo,QueryTopic is due to them having the same date, so its sorting by topicname 5131 $this->assert_str_equals( 5132 "OkBTopic,OkATopic,OkTopic,TestTopicSEARCH,WebPreferences,QueryTopicTwo,QueryTopic,QueryTopicThree", 5133 $result 5134 ); 4351 5135 4352 5136 #order=editby … … 4357 5141 4358 5142 # $this->assert_str_equals( "QueryTopicThree (Gerald),OkATopic (WikiGuest),OkBTopic (WikiGuest),OkTopic (WikiGuest),TestTopicSEARCH (WikiGuest),WebPreferences (WikiGuest),QueryTopicTwo (admin),QueryTopic (simon)", $result ); 4359 $this->assert_str_equals( 4360 "QueryTopicThree (Gerald),OkTopic (WikiGuest),OkBTopic (WikiGuest),WebPreferences (WikiGuest),TestTopicSEARCH (WikiGuest),OkATopic (WikiGuest),QueryTopicTwo (admin),QueryTopic (simon)", 5143 # $this->assert_str_equals( 5144 #"QueryTopicThree (Gerald),OkTopic (WikiGuest),OkBTopic (WikiGuest),WebPreferences (WikiGuest),TestTopicSEARCH (WikiGuest),OkATopic (WikiGuest),QueryTopicTwo (admin),QueryTopic (simon)", 5145 # $result 5146 # ); 5147 #needed to allow for store based differences in non-specified fields (ie, if sort on editby, then topic order is random - dependent on store impl) 5148 $this->assert_matches( 5149 qr/^QueryTopicThree \(Gerald\),.*WikiGuest\),QueryTopicTwo \(simon\),QueryTopic \(simon\)$/, 4361 5150 $result 4362 5151 ); … … 4369 5158 4370 5159 # $this->assert_str_equals( "QueryTopic (simon),QueryTopicTwo (admin),OkATopic (WikiGuest),OkBTopic (WikiGuest),OkTopic (WikiGuest),TestTopicSEARCH (WikiGuest),WebPreferences (WikiGuest),QueryTopicThree (Gerald)", $result ); 4371 $this->assert_str_equals( 4372 "QueryTopic (simon),QueryTopicTwo (admin),OkTopic (WikiGuest),OkBTopic (WikiGuest),WebPreferences (WikiGuest),TestTopicSEARCH (WikiGuest),OkATopic (WikiGuest),QueryTopicThree (Gerald)", 5160 # $this->assert_str_equals( 5161 #"QueryTopic (simon),QueryTopicTwo (admin),OkTopic (WikiGuest),OkBTopic (WikiGuest),WebPreferences (WikiGuest),TestTopicSEARCH (WikiGuest),OkATopic (WikiGuest),QueryTopicThree (Gerald)", 5162 # $result 5163 # ); 5164 #needed to allow for store based differences in non-specified fields (ie, if sort on editby, then topic order is random - dependent on store impl) 5165 $this->assert_matches( 5166 qr/^QueryTopicTwo \(simon\),QueryTopic \(simon\),.*\(WikiGuest\),QueryTopicThree \(Gerald\)$/, 4373 5167 $result 4374 5168 ); … … 4383 5177 4384 5178 #$this->assert_str_equals( "OkATopic (),OkBTopic (),OkTopic (),TestTopicSEARCH (),WebPreferences (),QueryTopicThree (2),QueryTopicTwo (7),QueryTopic (1234)", $result ); 4385 $this->assert_str_equals( 4386 "OkTopic (),OkBTopic (),WebPreferences (),TestTopicSEARCH (),OkATopic (),QueryTopicThree (2),QueryTopicTwo (7),QueryTopic (1234)", 5179 # $this->assert_str_equals( 5180 #"OkTopic (),OkBTopic (),WebPreferences (),TestTopicSEARCH (),OkATopic (),QueryTopicThree (2),QueryTopicTwo (7),QueryTopic (1234)", 5181 # $result 5182 # ); 5183 $this->assert_matches( 5184 qr/\(\),QueryTopicThree \(2\),QueryTopicTwo \(7\),QueryTopic \(1234\)$/, 4387 5185 $result 4388 5186 ); … … 4488 5286 ); 4489 5287 5288 return; 5289 } 5290 5291 sub verify_bad_order { 5292 my $this = shift; 5293 5294 $this->set_up_for_sorting(); 5295 my $search = 5296 '%SEARCH{".*" type="regex" scope="topic" web="' 5297 . $this->{test_web} 5298 . '" format="$topic" separator="," nonoise="on" '; 5299 my $result = 5300 $this->{test_topicObject} 5301 ->expandMacros( $search . 'order="formfield()"}%' ); 5302 5303 # Should get the default search order (or an error message, perhaps?) 5304 $this->assert_str_equals( 5305 "OkATopic,OkBTopic,OkTopic,QueryTopic,QueryTopicThree,QueryTopicTwo,TestTopicSEARCH,WebPreferences", 5306 $result 5307 ); 5308 5309 return; 4490 5310 } 4491 5311 … … 4501 5321 ); 4502 5322 4503 $this->assert_str_equals( '$web=TemporarySEARCHTestWebSEARCH', $result );5323 $this->assert_str_equals( "\$web=$this->{test_web}", $result ); 4504 5324 4505 5325 $result = $this->{test_topicObject}->expandMacros( … … 4515 5335 4516 5336 $this->assert_str_equals( 4517 'header: $web=TemporarySEARCHTestWebSEARCH<br />4518 format: $web=TemporarySEARCHTestWebSEARCH<br />4519 footer: $web=TemporarySEARCHTestWebSEARCH', $result5337 "header: \$web=$this->{test_web}<br /> 5338 format: \$web=$this->{test_web}<br /> 5339 footer: \$web=$this->{test_web}", $result 4520 5340 ); 4521 5341 … … 4532 5352 4533 5353 $this->assert_str_equals( 4534 '1 OkATopic5354 " 1 OkATopic 4535 5355 1 OkBTopic 4536 5356 1 OkTopic 4537 5357 1 TestTopicSEARCH 4538 5358 1 WebPreferences 4539 pagerformat: $web=TemporarySEARCHTestWebSEARCH', $result 4540 ); 5359 pagerformat: \$web=$this->{test_web}", $result 5360 ); 5361 5362 return; 4541 5363 } 4542 5364 … … 4555 5377 4556 5378 $this->assert_matches( qr/^FOO /, $result ); 5379 5380 return; 4557 5381 } 4558 5382 … … 4573 5397 %META:FIELD{name="Option" attributes="" title="Some option" value="Some long test I can truncate later"}% 4574 5398 METADATA 4575 my $topicObject=4576 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, $testTopic,4577 "---++ $header\n$body\n$meta\n");5399 my ($topicObject) = 5400 Foswiki::Func::readTopic( $this->{test_web}, $testTopic ); 5401 $topicObject->text("---++ $header\n$body\n$meta\n"); 4578 5402 $topicObject->save(); 4579 5403 … … 4646 5470 '$summary(noheader)' => qr/^\* Set ${nop}POTLEADER = ${nop}ScumBag$/, 4647 5471 '$pattern(.*?POTLEADER *= *([^\n]*).*)' => 'ScumBag', 4648 '$count(.*S.*)' => 2, # Headers are not matched5472 '$count(.*S.*)' => 2, # Not sure why... 4649 5473 ); 4650 5474 while ( my ( $token, $expected ) = each %testFormatTokens ) { … … 4662 5486 . "Expected:'$expected'\n But got:'$result'\n" ); 4663 5487 } 5488 $topicObject->finish(); 4664 5489 4665 5490 return; … … 4676 5501 4677 5502 Foswiki::Func::createWeb($testWeb); 4678 my $topicObject = 4679 Foswiki::Meta->new( $this->{session}, $testWeb, $testTopic, 4680 "begin $body end\n" ); 5503 my ($topicObject) = Foswiki::Func::readTopic( $testWeb, $testTopic ); 5504 $topicObject->text("begin $body end\n"); 4681 5505 $topicObject->save(); 4682 5506 my $expected = $topicObject->expandMacros($body); … … 4701 5525 "Expansion of SEARCH failed remotely (expandvariables=\"off\")!\n" 4702 5526 . "Expected:'$expectedFail'\n But got:'$result'\n" ); 5527 $topicObject->finish(); 4703 5528 return; 4704 5529 } … … 4723 5548 my $this = shift; 4724 5549 4725 my $topicObject=4726 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'VirtualBeer',4727 "There are alot of Virtual Beers to go around");5550 my ($topicObject) = 5551 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualBeer' ); 5552 $topicObject->text("There are alot of Virtual Beers to go around"); 4728 5553 $topicObject->save(); 4729 $topicObject =4730 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'RealBeer',4731 "There are alot of Virtual Beer to go around");5554 $topicObject->finish(); 5555 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'RealBeer' ); 5556 $topicObject->text("There are alot of Virtual Beer to go around"); 4732 5557 $topicObject->save(); 4733 $topicObject = 4734 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'FamouslyBeered', 4735 "Virtually speaking there could be alot of famous Beers" ); 5558 $topicObject->finish(); 5559 ($topicObject) = 5560 Foswiki::Func::readTopic( $this->{test_web}, 'FamouslyBeered' ); 5561 $topicObject->text( 5562 "Virtually speaking there could be alot of famous Beers"); 4736 5563 $topicObject->save(); 4737 $topicObject = 4738 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'VirtualLife', 4739 "In a all life, I would expect to find fine Beer" ); 5564 $topicObject->finish(); 5565 ($topicObject) = 5566 Foswiki::Func::readTopic( $this->{test_web}, 'VirtualLife' ); 5567 $topicObject->text("In a all life, I would expect to find fine Beer"); 4740 5568 $topicObject->save(); 4741 $topicObject =4742 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'NoLife',4743 "In a all life, I would expect to find fine Beer");5569 $topicObject->finish(); 5570 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'NoLife' ); 5571 $topicObject->text("In a all life, I would expect to find fine Beer"); 4744 5572 $topicObject->save(); 4745 $topicObject =4746 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'NoBeer',4747 "In a all life, I would expect to find fine Beer");5573 $topicObject->finish(); 5574 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'NoBeer' ); 5575 $topicObject->text("In a all life, I would expect to find fine Beer"); 4748 5576 $topicObject->save(); 4749 $topicObject =4750 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'SomeBeer',4751 "In a all life, I would expect to find fine Wine");5577 $topicObject->finish(); 5578 ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'SomeBeer' ); 5579 $topicObject->text("In a all life, I would expect to find fine Wine"); 4752 5580 $topicObject->save(); 5581 $topicObject->finish(); 4753 5582 4754 5583 my $result = … … 4815 5644 } 4816 5645 4817 # TaxonProfile/Builder.TermForm5646 #Profile/Builder.TermForm 4818 5647 sub verify_Item10269 { 4819 5648 my $this = shift; … … 4823 5652 my $result = 4824 5653 $this->{test_topicObject}->expandMacros( 4825 '%SEARCH{"NewField=\' TaxonProfile/Builder.TermForm\'"' . $stdCrap );5654 '%SEARCH{"NewField=\'Profile/Builder.TermForm\'"' . $stdCrap ); 4826 5655 $this->assert_str_equals( 'QueryTopicTwo', $result ); 5656 5657 return; 5658 } 5659 5660 #Profile/Builder.TermForm 5661 sub verify_Item10398 { 5662 my $this = shift; 5663 5664 $this->set_up_for_queries(); 5665 5666 my ($topicObject) = 5667 Foswiki::Func::readTopic( $this->{test_web}, 'Trash.MainBobTest' ); 5668 $topicObject->text("BLEEGLE blah/matchme.blah"); 5669 $topicObject->save(); 5670 $topicObject->finish(); 5671 5672 my $result = 5673 $this->{test_topicObject} 5674 ->expandMacros( '%SEARCH{"name=\'WebPreferences\'" type="query" web="' 5675 . $this->{test_web} 5676 . '" recurse="on" nonoise="on" format="$topic"}%' ); 5677 $this->assert_str_equals( 'WebPreferences', $result ); 5678 5679 return; 5680 } 5681 5682 #Item10515 5683 sub verify_lhs_lc_field_rhs_lc_string { 5684 my $this = shift; 5685 5686 $this->set_up_for_queries(); 5687 5688 my $result = 5689 $this->{test_topicObject} 5690 ->expandMacros( '%SEARCH{"lc(Firstname)=lc(\'JOHN\')"' . $stdCrap ); 5691 $this->assert_str_equals( 'QueryTopicTwo', $result ); 5692 5693 return; 4827 5694 } 4828 5695 … … 4833 5700 #$this->set_up_for_queries(); 4834 5701 4835 my $topicObject=4836 Foswiki:: Meta->new( $this->{session}, $this->{test_web}, 'Item10491',4837 <<TOPICTEXT);5702 my ($topicObject) = 5703 Foswiki::Func::readTopic( $this->{test_web}, 'Item10491' ); 5704 $topicObject->text(<<'TOPICTEXT' ); 4838 5705 Search on Foswiki.org has been showing some signs of corruption. The topic Tasks/Item968 appeared to be related, however it can be created From IRC: 4839 5706 … … 4883 5750 TOPICTEXT 4884 5751 $topicObject->save(); 5752 $topicObject->finish(); 4885 5753 4886 5754 my $result = … … 4890 5758 . '" scope="all" order="topic"}%' ); 4891 5759 $this->assert_str_equals( 4892 _cut_the_crap(<< RESULT), _cut_the_crap( $result . "\n" ) );5760 _cut_the_crap(<<"RESULT"), _cut_the_crap( $result . "\n" ) ); 4893 5761 <div class="foswikiSearchResultsHeader"><span>Searched: <b><noautolink>SomeString</noautolink></b></span><span id="foswikiNumberOfResultsContainer"></span></div> 4894 <h4 class="foswikiSearchResultsHeader" style="border-color: \#FF00FF"><b>Results from <nop>TemporarySEARCHTestWebSEARCHweb</b> retrieved at 04:34 (GMT)</h4>5762 <h4 class="foswikiSearchResultsHeader" style="border-color:#FF00FF"><b>Results from <nop>$this->{test_web} web</b> retrieved at 04:34 (GMT)</h4> 4895 5763 <div class="foswikiSearchResult"><div class="foswikiTopRow"> 4896 <a href="/~sven/core/bin/view/ TemporarySEARCHTestWebSEARCH/Item10491"><b>Item10491</b></a>5764 <a href="/~sven/core/bin/view/$this->{test_web}/Item10491"><b>Item10491</b></a> 4897 5765 <div class="foswikiSummary"><b>…</b> it can be created From <nop>IRC<nop>: <em><nop>SomeString</em>.txt So hopefully this topic <b>…</b> hits don't get corrupted. <em><nop>SomeString</em>? " txt<nop>: <nop>SomeString? And <b>…</b> ?tab=searchadvanced search=<em><nop>SomeString</em> scope=all order=topic type= <b>…</b> </div></div> 4898 <div class="foswikiBottomRow"><span class="foswikiSRRev"><span class="foswikiNew">NEW</span> - <a href="/~sven/core/bin/rdiff/ TemporarySEARCHTestWebSEARCH/Item10491" rel='nofollow'>16 Mar 2011 - 04:34</a></span> <span class="foswikiSRAuthor">by WikiGuest </span></div>5766 <div class="foswikiBottomRow"><span class="foswikiSRRev"><span class="foswikiNew">NEW</span> - <a href="/~sven/core/bin/rdiff/$this->{test_web}/Item10491" rel='nofollow'>16 Mar 2011 - 04:34</a></span> <span class="foswikiSRAuthor">by WikiGuest </span></div> 4899 5767 </div> 4900 5768 <div class="foswikiSearchResultCount">Number of topics: <span>1</span></div> 4901 5769 RESULT 5770 5771 return; 4902 5772 } 4903 5773 … … 4916 5786 $result 4917 5787 ); 5788 5789 return; 5790 } 5791 5792 sub verify_crossweb_op_ref { 5793 my $this = shift; 5794 my %topics = ( 5795 "$this->{test_web}/LLB/Analyses/Sequences.00001" => <<"HERE", 5796 %META:TOPICINFO{author="BaseUserMapping_333" date="1313039642" format="1.1" version="1"}% 5797 %META:TOPICPARENT{name="All"}% 5798 5799 %META:FORM{name="Profile/Definitions.Acacia_Sequence_Form"}% 5800 %META:FIELD{name="Acacia_TraceSet" title="TraceSet" type="llb+input" value="$this->{test_web}/LLB/Results/TraceSets.00001"}% 5801 %META:FIELD{name="Acacia_WorkState" title="Editing" type="list+one" value="done"}% 5802 %META:FIELD{name="Acacia_Complete" title="Complete" type="boolean" value="1"}% 5803 %META:FIELD{name="Acacia_DateCompleted" title="Date completed" type="date" value=""}% 5804 %META:FIELD{name="Acacia_GenbankNumber" title="Genbank number" type="text" value="AF523110"}% 5805 %META:FIELD{name="Acacia_GenbankLink" title="Genbank Link" type="text" value="http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=nucleotide&val=22725481"}% 5806 %META:FIELD{name="Acacia_SequenceNotes" title="Notes" type="richtext" value=""}% 5807 %META:FIELD{name="Acacia_Sequence" title="Sequence" type="llb+sequence" value="TCGGCTTTTAAGTGCGACTCAAAATTTTACACATTTCTATGAAGCAATGGATTCATCCATACCATCGGTAGAGTTTGTAAGACCACGACTGATCCAGAAAGGAATGAATGGAAAAAGCAGCATGTCGTATCAATGGAGAATTCTAAGACTATCTCATTTTTATTGGATCGGGCCCAAATCCATGTTTGTATTCTTGGCTCGCAACAAAAGCAAAAGAAATTCACAGTTGGGTTGAATTAATAAATGGATAGAGTTTGGTGACTCCAATTATAGGGAAACAAAAAGGAACGAGCTTTTGTTTTGAATTTGAATGATTCCCCCATCTAATTATACGTTAAAAATATAAAATATTAGTACTTGATGGGGGAAAAGCTTTTCCCATGAATGGATTATTGATTTTTGTTATGAATCCTAACTATTAGCTATTCTCCATTATAATTAGATTATGGGGTGGCGATAAATGTGTAGAAGAAAGAGTATATTGATAAAGATCTTTTTTTTTTTTCCAAAATCAAAAGAGCGATTGGGTTGAGAAAATAAAGGATTTCTAACTATCTTGTTATCCTAGAACGAACATAAAACAATTAGATGGAAAAAGCGAGTAGAGAGAGTCCGTTGATGAGTCTTACTTGTTTTCTAGGTATCTTTTTTTAGAATAGAATACCCTGTTTTGACTGTATCGCACTATGTATTATTTGATAACCCAATAAATCTTCGATCCTCGGCCCAAATCAAATTTCAAAAAATGGAGGAATTTCAAGTATATTTAGAACTAGATAGATCTCGTCAACATGACTTCCTATACCCACTTATTTTTCGGGAGTATATTTTTGCACTTGCTTACGATCATGGTTTAAATAGTTCCATTTTGGTGCAAGATCTAGGTTATGACAATAAATCTAGTTTACTAATTGTAAAACGTTTAATTACTCGAATGTATCACCAGAATCATTTGATTATTTCTGCTAATAATTCTAACAAAAATCCATTTTGGGGGTACAACAAGAATTTGTATTCTCAAATAATATCAGAGGGGCTTGCCGTCAGTGTGGAAATTCCATTTTCCCTACAACTAATCTCTTCCTTAGAGAAGGCAGAAATTATAAAATCCTATAATTTACGATCAATTCATTCAATATTTCCTTTTTTTGAGGAAAAATTTCCATATTTAAATTATGTGTCAGATGTACAAATACCCTACCCTATACATCTGGAAATCTTGATTCAAACCCTTCGATACTGGGTGAAAGATGCCTCCTCCTTTCATTTATTAAGGCTCTTTCTTTATGAGTATTGTAATTGGAATAGTCTTATTACTCCAAAAAAAAGGATTTCTACTTTTTCAAAAAGTAATCCAAGATTTTTCCTGTTCCTATATAATTTTTATGTAGGTGAATACGAATCCATCTTTCTTTTTCTCCGTAACAAATCTTCTTATTTACGATTAACATCTTCTGGAGTCTTTTTTGAACGAATCTATTTCTATGCAAAAATAAAACATTTTGTAGAAGTCTTTGATAAGGATTTTCCGTCCACCCTATGGTTCTTCAAGGACCCTTTCATTCATTATGTTAGATATCAAGGAAAATCCATTCTAGCTTCAAAGAATACGCCCTTTTTGATGAAAAAATGGAAATACTATCTTATCCATTTATGGCAATGTCATTTTTTTGTTTGGTCTCAACCAGGAAAGATCCATATAAACCAATTATCCGAGCATTCATTTTCCTTTTTGGGTTATTTTTCAAATGTGCGGCTAAATCCTTCAGTGGTACGGAGTCAAATGTTGGAAAAGTCATTTATAATGGAAAATCTTATGAAAAAGCTTGATACAATAATTCCAATTATTCCTCTAATTAGATCATTGGCTAAAGCAAATTTTTGTAATGTATTAGGACATCCCATTAGTAAGCCGGTCTGGGCCGATTCATCCGATTTTGATATTATTGAGCGATTTTTGCAGATATGCAGAGATCTCTCTCATTATTACAACGGATCCTCAAAAAAAAAGAGTTTGTATCGAATCAAAAAAAACTTCGGGCTTNNTGGATNAAAACTTTGGNGGGTAACNCCAAAAGTCCNNNCGGGTTTTTTAAAAAANTAGGTTTTNAANTANTGGAANAATTNTTTCANAGGAAAAAAANATTTTTTTTTTNATTTTTTCNANAGNTTTTTTTNCTTTGCNNAAGNTANAAAAAGGCGGNTTTGGGANTTTGAAANTTTTGANTTTCNNCNANGATNTGGGCCATCATGAAAAACNGGNTATCNNACNTTGANAANGGGAACNANCCNTNAATNNGGGAAAGATNAAAAAAAAAAGAATTCATTCGTTTCTATTATGAAATTTCTATTATGAAATATGAAATGGATTATGAAATGCTCATGTAGTAAGAGTAGGAATTGATAAACTAAGNACTTAACTTTTTTAGAGTCCNGTTCTAGGGAAGGAACTGAGGTTTAGATGTATACATAGGGAAAGCCGTGTGCAATGAAAAATGCAAGTACGGCCTGGGGAGGNNTTTTTTT"}% 5808 HERE 5809 "$this->{test_web}/LLB/Analyses/Sequences.00002" => <<"HERE", 5810 %META:TOPICINFO{author="BaseUserMapping_333" date="1313039642" format="1.1" version="1"}% 5811 %META:TOPICPARENT{name="All"}% 5812 5813 %META:FORM{name="Profile/Definitions.Acacia_Sequence_Form"}% 5814 %META:FIELD{name="Acacia_TraceSet" title="TraceSet" type="llb+input" value="$this->{test_web}/LLB/Results/TraceSets.00002"}% 5815 %META:FIELD{name="Acacia_WorkState" title="Editing" type="list+one" value="done"}% 5816 %META:FIELD{name="Acacia_Complete" title="Complete" type="boolean" value="1"}% 5817 %META:FIELD{name="Acacia_DateCompleted" title="Date completed" type="date" value=""}% 5818 %META:FIELD{name="Acacia_GenbankNumber" title="Genbank number" type="text" value="AF195707"}% 5819 %META:FIELD{name="Acacia_GenbankLink" title="Genbank Link" type="text" value="http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=nucleotide&val=10880548"}% 5820 %META:FIELD{name="Acacia_SequenceNotes" title="Notes" type="richtext" value=""}% 5821 %META:FIELD{name="Acacia_Sequence" title="Sequence" type="llb+sequence" value="AAAATCTTGGTCTTAATGTATACGAGTTTTTGAACGTAAAGGAGCAATAATTAATTTATTGTTCTATCAAGAGGGTTAATATTGCTCCTTTACTTTTTAGTAGTTTCATACATCAATTTTGTATTTACTTCAACATTCTTTACCGTTGTTTTAAGATAAGAAAAAAATATTGGAGTTTCATACTTTTTGTTTCTTTTTTACTAATTTATTTTATACGTTTTTTTCAGCAATCTTTCTTTATCTTTTGAAATGAAAAAAAAAAACAAAAGAAAGAATACAAATATCTCTGTAATTTTTAGATGGTTTTTAGATGGTATAGG"}% 5822 HERE 5823 "$this->{test_web}/LLB/Results/TraceSets.00001" => <<"HERE", 5824 %META:TOPICINFO{author="BaseUserMapping_333" date="1313040485" format="1.1" version="1"}% 5825 %META:TOPICPARENT{name="All"}% 5826 5827 %META:FORM{name="Profile/Definitions.Acacia_TraceSet_Form"}% 5828 %META:FIELD{name="Acacia_PCRProduct" title="PCR Product" type="llb+input" value="$this->{test_web}/LLB/Samples/PCRs.00001"}% 5829 HERE 5830 "$this->{test_web}/LLB/Results/TraceSets.00002" => <<"HERE", 5831 %META:TOPICINFO{author="BaseUserMapping_333" date="1313040748" format="1.1" version="1"}% 5832 %META:TOPICPARENT{name="All"}% 5833 5834 %META:FORM{name="Profile/Definitions.Acacia_TraceSet_Form"}% 5835 %META:FIELD{name="Acacia_PCRProduct" title="PCR Product" type="llb+input" value="$this->{test_web}/LLB/Samples/PCRs.00002"}% 5836 HERE 5837 "$this->{test_web}/LLB/Samples/PCRs.00001" => <<"HERE", 5838 %META:TOPICINFO{author="BaseUserMapping_333" date="1313038798" format="1.1" version="1"}% 5839 %META:TOPICPARENT{name="All"}% 5840 5841 %META:FORM{name="Profile/Definitions.Acacia_SamplePCR_Form"}% 5842 %META:FIELD{name="Acacia_Extract" title="Extract" type="llb+input" value="$this->{test_web}/LLB/Samples/Extracts.0000"}% 5843 %META:FIELD{name="Acacia_Gene" title="Gene" type="fwaddress" value="$this->{test_web}/LLB/Genes.MatK"}% 5844 %META:FIELD{name="Acacia_WorkState" title="PCR Done" type="list+one" value="working"}% 5845 %META:FIELD{name="Acacia_Cleaned" title="PCR Cleaned" type="boolean" value="1"}% 5846 %META:FIELD{name="Acacia_FreezerLocation" title="Freezer Location" type="text" value=""}% 5847 HERE 5848 "$this->{test_web}/LLB/Samples/PCRs.00002" => <<"HERE", 5849 %META:TOPICINFO{author="BaseUserMapping_333" date="1313038798" format="1.1" version="1"}% 5850 %META:TOPICPARENT{name="All"}% 5851 5852 %META:FORM{name="Profile/Definitions.Acacia_SamplePCR_Form"}% 5853 %META:FIELD{name="Acacia_Extract" title="Extract" type="llb+input" value="$this->{test_web}/LLB/Samples/Extracts.0000"}% 5854 %META:FIELD{name="Acacia_Gene" title="Gene" type="fwaddress" value="$this->{test_web}/LLB/Genes.PsbA"}% 5855 %META:FIELD{name="Acacia_WorkState" title="PCR Done" type="list+one" value="done"}% 5856 %META:FIELD{name="Acacia_Cleaned" title="PCR Cleaned" type="boolean" value="0"}% 5857 %META:FIELD{name="Acacia_FreezerLocation" title="Freezer Location" type="text" value=""}% 5858 HERE 5859 "$this->{test_web}/LLB/Samples/Extracts.0000" => <<"HERE", 5860 %META:TOPICINFO{author="BaseUserMapping_333" date="1313038766" format="1.1" version="1"}% 5861 %META:TOPICPARENT{name="All"}% 5862 5863 %META:FORM{name="Profile/Definitions.Acacia_Extract_Form"}% 5864 %META:FIELD{name="Acacia_Specimen" title="Specimen" type="llb+input" value="$this->{test_web}/LLB/Materials/Specimens.0120"}% 5865 %META:FIELD{name="Acacia_ExtractMethod" title="Extraction method" type="text" value="$this->{test_web}/LLB/Methods.10"}% 5866 %META:FIELD{name="Acacia_TissueType" title="Tissue type" type="list+one" value=""}% 5867 %META:FIELD{name="Acacia_DNAQuality" title="DNA quality" type="list+one" value="Wig L Bug"}% 5868 %META:FIELD{name="Acacia_DNAQuality" title="Picture" type="label" value=""}% 5869 %META:FIELD{name="Acacia_LaneNumber" title="Lane number" type="label" value="7"}% 5870 %META:FIELD{name="Acacia_PictureInfoFile" title="Picture info file" type="label" value=""}% 5871 %META:FIELD{name="Acacia_Concentration" title="Concentration (ng/<B5>L)" type="text" value=""}% 5872 %META:FIELD{name="Acacia_DNANotes" title="DNA Notes" type="text" value=""}% 5873 %META:FIELD{name="Acacia_FreezerLocation" title="Freezer Location" type="text" value=""}% 5874 HERE 5875 "$this->{test_web}/LLB/Samples/Extracts.0001" => <<"HERE" 5876 %META:TOPICINFO{author="BaseUserMapping_333" date="1313038766" format="1.1" version="1"}% 5877 %META:TOPICPARENT{name="All"}% 5878 5879 %META:FORM{name="Profile/Definitions.Acacia_Extract_Form"}% 5880 %META:FIELD{name="Acacia_Specimen" title="Specimen" type="llb+input" value="$this->{test_web}/LLB/Materials/Specimens.1220"}% 5881 %META:FIELD{name="Acacia_ExtractMethod" title="Extraction method" type="text" value="$this->{test_web}/LLB/Methods.03"}% 5882 %META:FIELD{name="Acacia_TissueType" title="Tissue type" type="list+one" value=""}% 5883 %META:FIELD{name="Acacia_DNAQuality" title="DNA quality" type="list+one" value=""}% 5884 %META:FIELD{name="Acacia_DNAQuality" title="Picture" type="label" value=""}% 5885 %META:FIELD{name="Acacia_LaneNumber" title="Lane number" type="label" value="3"}% 5886 %META:FIELD{name="Acacia_PictureInfoFile" title="Picture info file" type="label" value=""}% 5887 %META:FIELD{name="Acacia_Concentration" title="Concentration (ng/<B5>L)" type="text" value=""}% 5888 %META:FIELD{name="Acacia_DNANotes" title="DNA Notes" type="text" value=""}% 5889 %META:FIELD{name="Acacia_FreezerLocation" title="Freezer Location" type="text" value=""}% 5890 HERE 5891 ); 5892 my %tests = ( 5893 "Acacia_Specimen='$this->{test_web}/LLB/Materials/Specimens.1220'" => 5894 "$this->{test_web}/LLB/Samples/Extracts.0001", 5895 "Acacia_Extract/Acacia_ExtractMethod='$this->{test_web}/LLB/Methods.10'" 5896 => "$this->{test_web}/LLB/Samples/PCRs.00001, $this->{test_web}/LLB/Samples/PCRs.00002", 5897 "Acacia_ExtractMethod='$this->{test_web}/LLB/Methods.03'" => 5898 "$this->{test_web}/LLB/Samples/Extracts.0001", 5899 "Acacia_Extract/Acacia_ExtractMethod='$this->{test_web}/LLB/Methods.03'" 5900 => '', 5901 "Acacia_PCRProduct='$this->{test_web}/LLB/Samples/PCRs.00002'" => 5902 "$this->{test_web}/LLB/Results/TraceSets.00002", 5903 "Acacia_PCRProduct/Acacia_Extract/Acacia_ExtractMethod='$this->{test_web}/LLB/Methods.10'" 5904 => "$this->{test_web}/LLB/Results/TraceSets.00001, $this->{test_web}/LLB/Results/TraceSets.00002", 5905 "Acacia_TraceSet/Acacia_PCRProduct/Acacia_Extract/Acacia_ExtractMethod='$this->{test_web}/LLB/Methods.10'" 5906 => "$this->{test_web}/LLB/Analyses/Sequences.00001, $this->{test_web}/LLB/Analyses/Sequences.00002", 5907 "Acacia_TraceSet/Acacia_PCRProduct/Acacia_WorkState='done'" => 5908 "$this->{test_web}/LLB/Analyses/Sequences.00002", 5909 "Acacia_TraceSet/Acacia_PCRProduct/Acacia_Cleaned" => 5910 "$this->{test_web}/LLB/Analyses/Sequences.00001", 5911 "form.name='Profile/Definitions.Acacia_Sequence_Form' AND Acacia_TraceSet/Acacia_PCRProduct/Acacia_Extract/Acacia_LaneNumber > 5" 5912 => "$this->{test_web}/LLB/Analyses/Sequences.00001, $this->{test_web}/LLB/Analyses/Sequences.00002", 5913 "form.name='Profile/Definitions.Acacia_Sequence_Form' AND Acacia_TraceSet/Acacia_PCRProduct/Acacia_Extract/Acacia_LaneNumber < 5" 5914 => '' 5915 ); 5916 my $query = Unit::Request->new(''); 5917 5918 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 5919 5920 $this->createNewFoswikiSession( $Foswiki::cfg{AdminUserLogin}, $query ); 5921 $this->assert_str_equals( $this->{test_web}, $this->{session}->{webName} ); 5922 require Foswiki::Address; 5923 while ( my ( $fwaddress, $metatext ) = each %topics ) { 5924 my $addrObj = Foswiki::Address->new( string => $fwaddress ); 5925 my $topicObj; 5926 5927 if ( not Foswiki::Func::webExists( $addrObj->web() ) ) { 5928 my @webs; 5929 5930 foreach my $part ( @{ $addrObj->webpath() } ) { 5931 my $web; 5932 5933 push( @webs, $part ); 5934 $web = join( '/', @webs ); 5935 if ( not Foswiki::Func::webExists($web) ) { 5936 Foswiki::Func::createWeb( $web, '_default' ); 5937 } 5938 } 5939 } 5940 ($topicObj) = 5941 Foswiki::Func::readTopic( $addrObj->web(), $addrObj->topic() ); 5942 $topicObj->text($metatext); 5943 $topicObj->save(); 5944 $topicObj->finish(); 5945 } 5946 while ( my ( $querysearch, $expected ) = each %tests ) { 5947 my $result = 5948 $this->_test_query( $querysearch, "$this->{test_web}/LLB" ); 5949 $this->assert_str_equals( $expected, $result, 5950 "Testing: '$querysearch'\nExpected:'$expected'\nBut got: '$result'" 5951 ); 5952 5953 } 5954 5955 return; 5956 } 5957 5958 sub _test_query { 5959 my ( $this, $query, $web ) = @_; 5960 my $result = $this->{test_topicObject}->expandMacros(<<"HERE"); 5961 %SEARCH{ 5962 "$query" 5963 type="query" 5964 web="$web" 5965 recurse="on" 5966 nonoise="on" 5967 separator=", " 5968 format="\$web.\$topic" 5969 }% 5970 HERE 5971 chomp($result); 5972 5973 return $result; 4918 5974 } 4919 5975
Note: See TracChangeset
for help on using the changeset viewer.
