Changeset 13794


Ignore:
Timestamp:
01/23/12 07:00:46 (4 weeks ago)
Author:
PaulHarvey
Message:

Item11431: Clean UnitTests of Foswiki->new/finish

Committing what was 96 commits rebased on top of Foswikirev:13781. You
can view this full commit history at
 https://github.com/csirac2/UnitTestContrib/commits/Item11431-rebased

Tackling memory leaks, this effort seems to have saved 300MB and 10
minutes from the cost of running a full FoswikiSuite.

The recipe was:

  • Find and remove all Foswiki->new/finish calls with $this->createNewFoswikiSession()
  • Generally removed $fatwilly variables and replaced with $this->{session}, to avoid references to ->finish()'d Foswiki singleton/session objects
  • Addressed perlcriticisms in touched files
  • Convert Foswiki::Meta->new/load to Foswiki::Func::readTopic, for the sake of store2 re-integration
  • Call $topicObject->finish() where/whenever we can

Some of the tests in the default plugins need a little work, and
there's some uncommitted stuff against core lib/Foswiki.pm to help
assert SINGLE_SINGLETONS from Foswiki::new/::finish subs, we'll get
to that later...

Conflicts:

test/unit/AddressTests.pm
test/unit/AdminOnlyAccessControlTests.pm
test/unit/Fn_SEARCH.pm

Location:
branches/Release01x01/UnitTestContrib/test/unit
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x01/UnitTestContrib/test/unit/AccessControlTests.pm

    r13729 r13794  
    33use warnings; 
    44 
    5 use FoswikiFnTestCase; 
     5use FoswikiFnTestCase(); 
    66our @ISA = qw( FoswikiFnTestCase ); 
    77 
     
    4141    $this->SUPER::set_up(); 
    4242 
    43     my $topicObject = Foswiki::Meta->new( 
    44         $this->{session}, 
    45         $Foswiki::cfg{UsersWebName}, 
    46         $Foswiki::cfg{DefaultUserWikiName}, '' 
    47     ); 
    48     $topicObject->save(); 
     43    my ($topicObject) = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, 
     44        $Foswiki::cfg{DefaultUserWikiName} ); 
     45    $topicObject->text(''); 
     46    $topicObject->save(); 
     47    $topicObject->finish(); 
    4948    $this->registerUser( 'white', 'Mr', "White", 'white@example.com' ); 
    5049    $MrWhite = $this->{session}->{users}->getCanonicalUserID('white'); 
     
    5857    $MrYellow = $this->{session}->{users}->getCanonicalUserID('yellow'); 
    5958 
    60     $topicObject = 
    61       Foswiki::Meta->new( $this->{session}, $this->{users_web}, 
    62         "ReservoirDogsGroup", <<"THIS"); 
     59    $this->createNewFoswikiSession(); 
     60    ($topicObject) = 
     61      Foswiki::Func::readTopic( $this->{users_web}, "ReservoirDogsGroup" ); 
     62    $topicObject->text(<<"THIS"); 
    6363   * Set GROUP = MrWhite, $this->{users_web}.MrBlue 
    6464THIS 
    6565    $topicObject->save(); 
    66  
    67     return; 
    68 } 
    69  
    70 sub tear_down { 
    71     my $this = shift; 
    72     $this->SUPER::tear_down(); 
     66    $topicObject->finish(); 
    7367 
    7468    return; 
     
    7973    $web   ||= $this->{test_web}; 
    8074    $topic ||= $this->{test_topic}; 
    81     my $topicObject = Foswiki::Meta->load( $this->{session}, $web, $topic ); 
     75    my ($topicObject) = Foswiki::Func::readTopic( $web, $topic ); 
    8276    $this->assert( !$topicObject->haveAccess( $mode, $user ), 
    8377        "$user $mode $web.$topic" ); 
     
    106100        ); 
    107101    } 
     102    $topicObject->finish(); 
    108103 
    109104    return; 
     
    114109    $web   ||= $this->{test_web}; 
    115110    $topic ||= $this->{test_topic}; 
    116     my $topicObject = Foswiki::Meta->load( $this->{session}, $web, $topic ); 
     111    my ($topicObject) = Foswiki::Func::readTopic( $web, $topic ); 
    117112    $this->assert( $topicObject->haveAccess( $mode, $user ), 
    118113        "$user $mode $web.$topic" ); 
     
    141136        ); 
    142137    } 
     138    $topicObject->finish(); 
    143139 
    144140    return; 
     
    152148sub test_denytopic { 
    153149    my $this = shift; 
    154     my $topicObject = 
    155       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    156         $this->{test_topic}, <<"THIS"); 
     150    my ($topicObject) = 
     151      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     152    $topicObject->text(<<"THIS"); 
    157153If DENYTOPIC is set to a list of wikinames 
    158154    * people in the list will be DENIED. 
     
    161157THIS 
    162158    $topicObject->save(); 
    163  
    164     $this->{session}->finish(); 
    165     $this->{session} = Foswiki->new(); 
    166  
     159    $topicObject->finish(); 
     160 
     161    $this->createNewFoswikiSession(); 
    167162    $this->PERMITTED( "VIEW", $MrGreen ); 
    168163    $this->DENIED( "VIEW", $MrYellow ); 
     
    177172sub test_empty_denytopic { 
    178173    my $this = shift; 
    179     my $topicObject = 
    180       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    181         $this->{test_topic}, <<'THIS'); 
     174    my ($topicObject) = 
     175      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     176    $topicObject->text(<<'THIS'); 
    182177If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 
    183178    * access is PERMITTED _i.e _ no-one is denied access to this topic 
     
    185180THIS 
    186181    $topicObject->save(); 
    187  
    188     $this->{session}->finish(); 
    189     $this->{session} = Foswiki->new(); 
     182    $topicObject->finish(); 
     183 
     184    $this->createNewFoswikiSession(); 
    190185    $this->PERMITTED( "VIEW", $MrGreen ); 
    191186    $this->PERMITTED( "VIEW", $MrYellow ); 
     
    200195sub test_whitespace_denytopic { 
    201196    my $this = shift; 
    202     my $topicObject = 
    203       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    204         $this->{test_topic}, <<'THIS'); 
     197    my ($topicObject) = 
     198      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     199    $topicObject->text(<<'THIS'); 
    205200If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 
    206201    * access is PERMITTED _i.e _ no-one is denied access to this topic 
     
    208203THIS 
    209204    $topicObject->save(); 
    210  
    211     $this->{session}->finish(); 
    212     $this->{session} = Foswiki->new(); 
     205    $topicObject->finish(); 
     206 
     207    $this->createNewFoswikiSession(); 
    213208    $this->PERMITTED( "VIEW", $MrGreen ); 
    214209    $this->PERMITTED( "VIEW", $MrYellow ); 
     
    223218sub test_denytopic_whitespace { 
    224219    my $this = shift; 
    225     my $topicObject = 
    226       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    227         $this->{test_topic}, <<'THIS'); 
     220    my ($topicObject) = 
     221      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     222    $topicObject->text(<<'THIS'); 
    228223If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 
    229224    * access is PERMITTED _i.e _ no-one is denied access to this topic 
     
    231226THIS 
    232227    $topicObject->save(); 
    233  
    234     $this->{session}->finish(); 
    235     $this->{session} = Foswiki->new(); 
     228    $topicObject->finish(); 
     229 
     230    $this->createNewFoswikiSession(); 
    236231    $this->PERMITTED( "VIEW", $MrGreen ); 
    237232    $this->PERMITTED( "VIEW", $MrYellow ); 
     
    246241sub test_allowtopic { 
    247242    my $this = shift; 
    248     my $topicObject = 
    249       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    250         $this->{test_topic}, <<'THIS'); 
     243    my ($topicObject) = 
     244      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     245    $topicObject->text(<<'THIS'); 
    251246If ALLOWTOPIC is set 
    252247   1. people in the list are PERMITTED 
     
    255250THIS 
    256251    $topicObject->save(); 
    257  
    258     $this->{session}->finish(); 
    259     $this->{session} = Foswiki->new(); 
     252    $topicObject->finish(); 
     253 
     254    $this->createNewFoswikiSession(); 
    260255    $this->PERMITTED( "VIEW", $MrOrange ); 
    261256    $this->DENIED( "VIEW", $MrGreen ); 
     
    271266sub test_allowtopic_a { 
    272267    my $this = shift; 
    273     my $topicObject = 
    274       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    275         $this->{test_topic}, <<'THIS'); 
     268    my ($topicObject) = 
     269      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     270    $topicObject->text(<<'THIS'); 
    276271If ALLOWTOPIC is set 
    277272   1. people in the list are PERMITTED 
     
    280275THIS 
    281276    $topicObject->save(); 
     277    $topicObject->finish(); 
    282278 
    283279    my $topicquery = Unit::Request->new(""); 
     
    285281 
    286282    # renew Foswiki, so WebPreferences gets re-read 
    287     $this->{session}->finish(); 
    288     $this->{session} = Foswiki->new( undef, $topicquery ); 
     283    $this->createNewFoswikiSession(); 
    289284    $this->PERMITTED( "VIEW", $MrOrange ); 
    290     $this->{session}->finish(); 
    291     $this->{session} = Foswiki->new( undef, $topicquery ); 
     285    $this->createNewFoswikiSession( undef, $topicquery ); 
    292286    $this->DENIED( "VIEW", $MrGreen ); 
    293     $this->{session}->finish(); 
    294     $this->{session} = Foswiki->new( undef, $topicquery ); 
     287    $this->createNewFoswikiSession( undef, $topicquery ); 
    295288    $this->DENIED( "VIEW", $MrYellow ); 
    296     $this->{session}->finish(); 
    297     $this->{session} = Foswiki->new( undef, $topicquery ); 
     289    $this->createNewFoswikiSession( undef, $topicquery ); 
    298290    $this->DENIED( "VIEW", $MrWhite ); 
    299     $this->{session}->finish(); 
    300     $this->{session} = Foswiki->new( undef, $topicquery ); 
     291    $this->createNewFoswikiSession( undef, $topicquery ); 
    301292    $this->DENIED( "view", $MrBlue ); 
    302293 
     
    309300sub test_allowtopic_b { 
    310301    my $this = shift; 
    311     my $topicObject = 
    312       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    313         $this->{test_topic}, <<'THIS'); 
     302    my ($topicObject) = 
     303      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     304    $topicObject->text(<<'THIS'); 
    314305If ALLOWTOPIC is set 
    315306   1. people in the list are PERMITTED 
     
    318309THIS 
    319310    $topicObject->save(); 
     311    $topicObject->finish(); 
    320312 
    321313    # renew Foswiki, so WebPreferences gets re-read 
    322     $this->{session}->finish(); 
    323     $this->{session} = Foswiki->new(); 
     314    $this->createNewFoswikiSession(); 
    324315    $this->PERMITTED( "VIEW", $MrOrange ); 
    325     $this->{session}->finish(); 
    326     $this->{session} = Foswiki->new(); 
     316    $this->createNewFoswikiSession(); 
    327317    $this->DENIED( "VIEW", $MrGreen ); 
    328     $this->{session}->finish(); 
    329     $this->{session} = Foswiki->new(); 
     318    $this->createNewFoswikiSession(); 
    330319    $this->DENIED( "VIEW", $MrYellow ); 
    331     $this->{session}->finish(); 
    332     $this->{session} = Foswiki->new(); 
     320    $this->createNewFoswikiSession(); 
    333321    $this->DENIED( "VIEW", $MrWhite ); 
    334     $this->{session}->finish(); 
    335     $this->{session} = Foswiki->new(); 
     322    $this->createNewFoswikiSession(); 
    336323    $this->DENIED( "view", $MrBlue ); 
    337324 
     
    343330sub test_allowtopic_c { 
    344331    my $this = shift; 
    345     my $topicObject = 
    346       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    347         $this->{test_topic}, <<'THIS'); 
     332    my ($topicObject) = 
     333      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     334    $topicObject->text(<<'THIS'); 
    348335If ALLOWTOPIC is set 
    349336   1. people in the list are PERMITTED 
     
    360347    ); 
    361348    $topicObject->save(); 
     349    $topicObject->finish(); 
    362350 
    363351    # renew Foswiki, so WebPreferences gets re-read 
    364     $this->{session}->finish(); 
    365     $this->{session} = Foswiki->new(); 
     352    $this->createNewFoswikiSession(); 
    366353    $this->PERMITTED( "VIEW", $MrOrange ); 
    367     $this->{session}->finish(); 
    368     $this->{session} = Foswiki->new(); 
     354    $this->createNewFoswikiSession(); 
    369355    $this->DENIED( "VIEW", $MrGreen ); 
    370     $this->{session}->finish(); 
    371     $this->{session} = Foswiki->new(); 
     356    $this->createNewFoswikiSession(); 
    372357    $this->PERMITTED( "VIEW", $MrYellow ); 
    373     $this->{session}->finish(); 
    374     $this->{session} = Foswiki->new(); 
     358    $this->createNewFoswikiSession(); 
    375359    $this->DENIED( "VIEW", $MrWhite ); 
    376     $this->{session}->finish(); 
    377     $this->{session} = Foswiki->new(); 
     360    $this->createNewFoswikiSession(); 
    378361    $this->DENIED( "view", $MrBlue ); 
    379362 
     
    384367sub test_denyweb { 
    385368    my $this = shift; 
    386     my $topicObject = 
    387       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    388         $Foswiki::cfg{WebPrefsTopicName}, <<"THIS"); 
     369    my ($topicObject) = 
     370      Foswiki::Func::readTopic( $this->{test_web}, 
     371        $Foswiki::cfg{WebPrefsTopicName} ); 
     372    $topicObject->text(<<"THIS"); 
    389373If DENYWEB is set to a list of wikiname 
    390374    * people in the list are DENIED access 
     
    392376THIS 
    393377    $topicObject->save(); 
     378    $topicObject->finish(); 
    394379 
    395380    # renew Foswiki, so WebPreferences gets re-read 
    396     $this->{session}->finish(); 
    397     $this->{session} = Foswiki->new(); 
    398     $topicObject = Foswiki::Meta->new( 
    399         $this->{session},    $this->{test_web}, 
    400         $this->{test_topic}, "Null points" 
    401     ); 
    402     $topicObject->save(); 
     381    $this->createNewFoswikiSession(); 
     382    ($topicObject) = 
     383      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     384    $topicObject->text("Null points"); 
     385    $topicObject->save(); 
     386    $topicObject->finish(); 
     387 
    403388    $this->DENIED( "VIEW", $MrOrange ); 
    404389    $this->PERMITTED( "VIEW", $MrGreen ); 
     
    412397# Test that ALLOWWEB works in a top-level web with no finalisation 
    413398sub test_allow_web { 
    414     my $this        = shift; 
    415     my $topicObject = Foswiki::Meta->new( 
    416         $this->{session}, 
    417         $this->{test_web}, $Foswiki::cfg{WebPrefsTopicName}, 
     399    my $this = shift; 
     400    my ($topicObject) = 
     401      Foswiki::Func::readTopic( $this->{test_web}, 
     402        $Foswiki::cfg{WebPrefsTopicName} ); 
     403    $topicObject->text( 
    418404        <<'THIS' 
    419405If ALLOWWEB is set to a list of wikinames 
     
    422408   * Set ALLOWWEBVIEW = MrGreen MrYellow MrWhite 
    423409THIS 
    424         , undef 
    425     ); 
    426     $topicObject->save(); 
     410    ); 
     411    $topicObject->save(); 
     412    $topicObject->finish(); 
    427413 
    428414    # renew Foswiki, so WebPreferences gets re-read 
    429     $this->{session}->finish(); 
    430     $this->{session} = Foswiki->new(); 
    431     $topicObject = Foswiki::Meta->new( 
    432         $this->{session},    $this->{test_web}, 
    433         $this->{test_topic}, "Null points" 
    434     ); 
    435     $topicObject->save(); 
     415    $this->createNewFoswikiSession(); 
     416    ($topicObject) = 
     417      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     418    $topicObject->text("Null points"); 
     419    $topicObject->save(); 
     420    $topicObject->finish(); 
    436421    $this->DENIED( "VIEW", $MrOrange ); 
    437422    $this->PERMITTED( "VIEW", $MrGreen ); 
     
    445430# Test that Web.UserName is equivalent to UserName in ACLs 
    446431sub test_webDotUserName { 
    447     my $this        = shift; 
    448     my $topicObject = Foswiki::Meta->new( 
    449         $this->{session}, $this->{test_web}, $this->{test_topic}, 
     432    my $this = shift; 
     433    my ($topicObject) = 
     434      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     435    $topicObject->text( 
    450436        <<'THIS' 
    451437If ALLOWTOPIC is set 
     
    454440   * Set ALLOWTOPICVIEW = MrYellow,%USERSWEB%.MrOrange,Nosuchweb.MrGreen,%MAINWEB%.MrBlue,%SYSTEMWEB%.MrWhite 
    455441THIS 
    456         , undef 
    457     ); 
    458     $topicObject->save(); 
    459     $this->{session}->finish(); 
    460     $this->{session} = Foswiki->new(); 
     442    ); 
     443    $topicObject->save(); 
     444    $topicObject->finish(); 
     445    $this->createNewFoswikiSession(); 
    461446    $this->PERMITTED( "VIEW", $MrOrange ); 
    462447    $this->DENIED( "VIEW", $MrGreen ); 
     
    502487   * Set ALLOWTOPICVIEW = %USERSWEB%.MrGreen 
    503488THIS 
    504     my $topicObject = 
    505       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    506         $this->{test_topic}, $text ); 
    507     $topicObject->save(); 
    508     $this->{session}->finish(); 
    509  
    510     $this->{session} = Foswiki->new(); 
    511     $topicObject = 
    512       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    513         $this->{test_topic} ); 
     489    my ($topicObject) = 
     490      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     491    $topicObject->text($text); 
     492    $topicObject->save(); 
     493    $topicObject->finish(); 
     494    $this->createNewFoswikiSession(); 
     495 
     496    ($topicObject) = 
     497      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
    514498    $this->_checkSettings($topicObject); 
     499    $topicObject->finish(); 
    515500 
    516501    return; 
     
    521506    my $this = shift; 
    522507 
    523     my $topicObject = 
    524       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    525         $this->{test_topic}, 'Empty' ); 
     508    my ($topicObject) = 
     509      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     510    $topicObject->text('Empty'); 
    526511    my $args = { 
    527512        name  => 'ALLOWTOPICVIEW', 
     
    532517    $topicObject->putKeyed( 'PREFERENCE', $args ); 
    533518    $topicObject->save(); 
    534     $this->{session}->finish(); 
    535  
    536     $this->{session} = Foswiki->new(); 
    537     $topicObject = 
    538       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    539         $this->{test_topic} ); 
     519    $topicObject->finish(); 
     520    $this->createNewFoswikiSession(); 
     521 
     522    ($topicObject) = 
     523      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
    540524 
    541525    $this->_checkSettings($topicObject); 
     526    $topicObject->finish(); 
    542527 
    543528    return; 
     
    551536   * Set ALLOWTOPICVIEW = %USERSWEB%.MrOrange 
    552537THIS 
    553     my $topicObject = 
    554       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    555         $this->{test_topic}, $text ); 
     538    my ($topicObject) = 
     539      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     540    $topicObject->text($text); 
    556541    my $args = { 
    557542        name  => 'ALLOWTOPICVIEW', 
     
    562547    $topicObject->putKeyed( 'PREFERENCE', $args ); 
    563548    $topicObject->save(); 
    564     $this->{session}->finish(); 
    565  
    566     $this->{session} = Foswiki->new(); 
    567     $topicObject = 
    568       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    569         $this->{test_topic} ); 
     549    $topicObject->finish(); 
     550    $this->createNewFoswikiSession(); 
     551 
     552    ($topicObject) = 
     553      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
    570554    $this->_checkSettings($topicObject); 
     555    $topicObject->finish(); 
    571556 
    572557    return; 
     
    581566 
    582567    # First build a parent web with view restricted to MrGreen 
    583     my $topicObject = 
    584       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    585         $this->{test_topic}, "Nowt" ); 
    586     $topicObject->save(); 
    587  
    588     $topicObject = 
    589       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    590         $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 
     568    my ($topicObject) = 
     569      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     570    $topicObject->text("Nowt"); 
     571    $topicObject->save(); 
     572    $topicObject->finish(); 
     573 
     574    ($topicObject) = 
     575      Foswiki::Func::readTopic( $this->{test_web}, 
     576        $Foswiki::cfg{WebPrefsTopicName} ); 
     577    $topicObject->text(<<'THIS'); 
    591578   * Set ALLOWWEBVIEW = MrGreen 
    592579THIS 
    593580    $topicObject->save(); 
     581    $topicObject->finish(); 
    594582 
    595583    # Now build a subweb with view restricted to MrOrange 
    596584    my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 
    597585    $webObject->populateNewWeb(); 
    598     $topicObject = 
    599       Foswiki::Meta->new( $this->{session}, $subweb, 
    600         $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 
     586    $webObject->finish(); 
     587    ($topicObject) = 
     588      Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 
     589    $topicObject->text(<<'THIS'); 
    601590   * Set ALLOWWEBVIEW = MrOrange 
    602591THIS 
    603592    $topicObject->save(); 
    604     $this->{session}->finish(); 
     593    $topicObject->finish(); 
    605594 
    606595    # Ensure that MrOrange can read the subweb and MrGreen the parent web 
    607     $this->{session} = Foswiki->new(); 
     596    $this->createNewFoswikiSession(); 
    608597    $this->PERMITTED( "VIEW", $MrOrange, $subweb ); 
    609598    $this->DENIED( "VIEW", $MrGreen, $subweb ); 
     
    623612    # First build a parent web with view restricted to MrGreen, and 
    624613    # finalise the setting 
    625     my $topicObject = 
    626       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    627         $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 
     614    my ($topicObject) = 
     615      Foswiki::Func::readTopic( $this->{test_web}, 
     616        $Foswiki::cfg{WebPrefsTopicName} ); 
     617    $topicObject->text(<<'THIS'); 
    628618   * Set ALLOWWEBVIEW = MrGreen 
    629619   * Set FINALPREFERENCES = ALLOWWEBVIEW 
    630620THIS 
    631621    $topicObject->save(); 
     622    $topicObject->finish(); 
    632623 
    633624    # Now build a subweb with no restrictions 
    634625    my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 
    635626    $webObject->populateNewWeb(); 
    636     $topicObject = 
    637       Foswiki::Meta->new( $this->{session}, $subweb, 
    638         $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 
    639 THIS 
    640     $topicObject->save(); 
    641     $this->{session}->finish(); 
    642  
    643     $this->{session} = Foswiki->new(); 
     627    $webObject->finish(); 
     628    ($topicObject) = 
     629      Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 
     630    $topicObject->text(<<'THIS'); 
     631THIS 
     632    $topicObject->save(); 
     633    $topicObject->finish(); 
     634 
     635    $this->createNewFoswikiSession(); 
    644636    $this->PERMITTED( "VIEW", $MrGreen, $subweb ); 
    645637    $this->DENIED( "VIEW", $MrOrange, $subweb ); 
     
    659651    # First build a parent web with view restricted to MrGreen, and 
    660652    # finalise the setting 
    661     my $topicObject = 
    662       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    663         $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 
     653    my ($topicObject) = 
     654      Foswiki::Func::readTopic( $this->{test_web}, 
     655        $Foswiki::cfg{WebPrefsTopicName} ); 
     656    $topicObject->text(<<'THIS'); 
    664657   * Set ALLOWWEBVIEW = MrGreen 
    665658   * Set FINALPREFERENCES = ALLOWWEBVIEW 
    666659THIS 
    667660    $topicObject->save(); 
     661    $topicObject->finish(); 
    668662 
    669663    # Now build a subweb with view restricted to MrOrange 
    670664    my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 
    671665    $webObject->populateNewWeb(); 
    672     $topicObject = 
    673       Foswiki::Meta->new( $this->{session}, $subweb, 
    674         $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 
     666    $webObject->finish(); 
     667    ($topicObject) = 
     668      Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 
     669    $topicObject->text(<<'THIS'); 
    675670   * Set ALLOWWEBVIEW = MrOrange 
    676671THIS 
    677672    $topicObject->save(); 
    678     $this->{session}->finish(); 
    679  
    680     $this->{session} = Foswiki->new(); 
     673    $topicObject->finish(); 
     674    $this->createNewFoswikiSession(); 
     675 
    681676    $this->DENIED( "VIEW", $MrOrange, $subweb ); 
    682677    $this->PERMITTED( "VIEW", $MrGreen, $subweb ); 
     
    696691 
    697692    # Create a topic with an anchor, viewable only by MrYellow 
    698     my $topicObject = Foswiki::Meta->new( 
    699         $this->{session}, $this->{test_web}, $test_topic, 
    700         <<'THIS' 
     693    my ($topicObject) = 
     694      Foswiki::Func::readTopic( $this->{test_web}, $test_topic ); 
     695    $topicObject->text(<<'THIS'); 
    701696If there is an anchor, and some access restrictions, 
    702697anchor is preserved after login. 
     
    704699   * Set ALLOWTOPICVIEW = MrYellow 
    705700THIS 
    706         , undef 
    707     ); 
    708     $topicObject->save(); 
     701    $topicObject->save(); 
     702    $topicObject->finish(); 
    709703 
    710704    # Request the page with the full UI 
     
    720714    my $viewUrl = 
    721715      $this->{session} 
    722       ->getScriptUrl( '0', 'view', $this->{test_web}, $test_topic ); 
     716      ->getScriptUrl( 0, 'view', $this->{test_web}, $test_topic ); 
    723717    $query->uri("$viewUrl"); 
     718    $this->finishFoswikiSession(); 
    724719    my ($text) = $this->capture( 
    725720        sub { 
    726             $Foswiki::Plugins::SESSION->{response} = 
    727               Foswiki::UI::handleRequest($query); 
     721            my $response = Foswiki::UI::handleRequest($query); 
     722            $this->createNewFoswikiSession( undef, $query ); 
     723            $this->{session}{response} = $response; 
    728724        } 
    729725    ); 
     
    732728    my $loginUrl = 
    733729      $this->{session} 
    734       ->getScriptUrl( '0', 'login', $this->{test_web}, $test_topic ); 
     730      ->getScriptUrl( 0, 'login', $this->{test_web}, $test_topic ); 
    735731 
    736732    # Item11121: the test doesn't tolerate ShortURLs, for example. 
     
    748744 
    749745    # Check the redirect contains the login url + view to this topic 
    750     $this->assert_matches( 
    751         qr#^$loginUrl.*/view/$this->{test_web}/$test_topic$#, 
    752         $redirect_to, 
    753         "Login did not redirect to a page with the proper anchor:\n" 
     746    my $regex = qr#^\Q$loginUrl\E.*/view/$this->{test_web}/$test_topic$#; 
     747    $this->assert_matches( $regex, $redirect_to, 
     748            "Login did not redirect to a page with the proper anchor:\n" 
    754749          . "Location: $redirect_to\n" 
    755           . "Expected: ^$loginUrl.*\%23anchor\$" 
    756     ); 
     750          . "Expected: $regex" ); 
    757751 
    758752    # Get the redirected page after login 
  • branches/Release01x01/UnitTestContrib/test/unit/AttrsTests.pm

    r13729 r13794  
     1package AttrsTests; 
    12use strict; 
    2  
    3 package AttrsTests; 
    4  
    5 use FoswikiTestCase; 
     3use warnings; 
     4 
     5use FoswikiTestCase(); 
    66our @ISA = qw( FoswikiTestCase ); 
    77 
    8 use Foswiki::Attrs; 
     8use Foswiki::Attrs(); 
    99 
    1010sub new { 
  • branches/Release01x01/UnitTestContrib/test/unit/CacheTests.pm

    r13729 r13794  
    11package CacheTests; 
     2use strict; 
     3use warnings; 
    24 
    3 use FoswikiFnTestCase; 
     5use FoswikiFnTestCase(); 
    46our @ISA = qw( FoswikiFnTestCase ); 
    57 
    6 use strict; 
    7 use Foswiki; 
    8 use Foswiki::Meta; 
     8use Foswiki(); 
     9use Foswiki::Meta(); 
     10use File::Spec(); 
     11use Foswiki::OopsException(); 
     12use Foswiki::PageCache(); 
    913use Error qw( :try ); 
    10 use Foswiki::OopsException; 
    11 use Foswiki::PageCache; 
    1214use Benchmark qw(:hireswallclock); 
    1315 
     
    1719    my $this = shift; 
    1820    my @page; 
     21 
    1922    foreach my $dir (@INC) { 
    20         if ( opendir( D, "$dir/Foswiki/Cache" ) ) { 
    21             foreach my $alg ( readdir D ) { 
     23        if ( opendir( my $D, File::Spec->catdir( $dir, 'Foswiki', 'Cache' ) ) ) 
     24        { 
     25            foreach my $alg ( readdir $D ) { 
    2226                next unless $alg =~ s/^(.*)\.pm$/$1/; 
    23                 next if defined &$alg; 
     27                next if defined &{$alg}; 
    2428                $ENV{PATH} =~ /^(.*)$/ms; 
    25                 $ENV{PATH} = $1; 
     29                local $ENV{PATH} = $1; 
    2630                ($alg) = $alg =~ /^(.*)$/ms; 
    27                 eval "require Foswiki::Cache::$alg"; 
    28                 if ($@) { 
    29                     print STDERR 
    30 "Cannot test Foswiki::Cache::$alg\nCompilation error when trying to 'require' it\n"; 
    31                 } 
    32                 else { 
     31 
     32                if ( eval "require Foswiki::Cache::$alg; 1;" ) { 
    3333                    no strict 'refs'; 
    34                     *$alg = sub { 
     34                    *{$alg} = sub { 
    3535                        my $this = shift; 
    3636                        $Foswiki::cfg{CacheManager} = 'Foswiki::Cache::' . $alg; 
     
    3939                    push( @page, $alg ); 
    4040                } 
     41                else { 
     42                    print STDERR 
     43"Cannot test Foswiki::Cache::$alg\nCompilation error when trying to 'require' it\n"; 
     44                } 
    4145            } 
    42             closedir(D); 
     46            closedir($D); 
    4347        } 
    4448    } 
     
    5054sub DBFileMeta { 
    5155    $Foswiki::cfg{MetaCacheManager} = 'Foswiki::Cache::DB_File'; 
     56 
     57    return; 
    5258} 
    5359 
    5460sub BDBMeta { 
    5561    $Foswiki::cfg{MetaCacheManager} = 'Foswiki::Cache::BDB'; 
     62 
     63    return; 
    5664} 
    5765 
     
    5967    $Foswiki::cfg{HttpCompress} = 1; 
    6068    $Foswiki::cfg{Cache}{Compress} = 1; 
     69 
     70    return; 
    6171} 
    6272 
     
    6474    $Foswiki::cfg{HttpCompress} = 0; 
    6575    $Foswiki::cfg{Cache}{Compress} = 0; 
     76 
     77    return; 
    6678} 
    6779 
     
    90102    $Foswiki::cfg{Cache}{Compress} = 0; 
    91103    $UI_FN ||= $this->getUIFn('view'); 
    92 } 
    93104 
    94 sub tear_down { 
    95     my $this = shift; 
    96     $this->SUPER::tear_down(); 
     105    return; 
    97106} 
    98107 
     
    102111    $UI_FN ||= $this->getUIFn('view'); 
    103112 
    104     my $query = new Unit::Request( { skin => ['none'], } ); 
     113    my $query = Unit::Request->new( { skin => ['none'], } ); 
    105114    $query->path_info("/"); 
    106115    $query->method('POST'); 
    107116 
    108     my $fatwilly = new Foswiki( $this->{test_user_login}, $query ); 
     117    $this->createNewFoswikiSession( $this->{test_user_login}, $query ); 
    109118 
    110119    # This first request should *not* be satisfied from the cache, but 
    111120    # the cache should be populated with the result. 
    112     my $p1start = new Benchmark(); 
     121    my $p1start = Benchmark->new(); 
    113122    my ($one) = $this->capture( 
    114123        sub { 
    115124            no strict 'refs'; 
    116             &$UI_FN($fatwilly); 
     125            &{$UI_FN}( $this->{session} ); 
    117126            use strict 'refs'; 
    118             $Foswiki::engine->finalize( $fatwilly->{response}, 
    119                 $fatwilly->{request} ); 
     127            $Foswiki::engine->finalize( $this->{session}{response}, 
     128                $this->{session}{request} ); 
    120129        } 
    121130    ); 
    122131 
    123     my $p1end = new Benchmark(); 
     132    my $p1end = Benchmark->new(); 
    124133    print STDERR "R1 " . timestr( timediff( $p1end, $p1start ) ) . "\n"; 
    125     $fatwilly->finish(); 
    126134 
    127     $fatwilly = new Foswiki( $this->{test_user_login}, $query ); 
     135    $this->createNewFoswikiSession( $this->{test_user_login}, $query ); 
    128136 
    129137    # This second request should be satisfied from the cache 
    130     my $p2start = new Benchmark(); 
     138    my $p2start = Benchmark->new(); 
    131139    my ($two) = $this->capture( 
    132140        sub { 
    133141            no strict 'refs'; 
    134             &$UI_FN($fatwilly); 
     142            &{$UI_FN}( $this->{session} ); 
    135143            use strict 'refs'; 
    136             $Foswiki::engine->finalize( $fatwilly->{response}, 
    137                 $fatwilly->{request} ); 
     144            $Foswiki::engine->finalize( $this->{session}{response}, 
     145                $this->{session}{request} ); 
    138146        } 
    139147    ); 
    140     my $p2end = new Benchmark(); 
     148    my $p2end = Benchmark->new(); 
    141149    print STDERR "R2 " . timestr( timediff( $p2end, $p2start ) ) . "\n"; 
    142     $fatwilly->finish(); 
    143150 
    144151    # Massage the HTML for comparison 
     
    164171 
    165172    $this->assert_html_equals( $one, $two ); 
     173 
     174    return; 
    166175} 
    167176 
  • branches/Release01x01/UnitTestContrib/test/unit/ClientTests.pm

    r13729 r13794  
     1package ClientTests; 
    12use strict; 
    2  
    3 package ClientTests; 
     3use warnings; 
    44 
    55# This is woefully incomplete, but it does at least check that 
    66# LoginManager.pm compiles okay. 
    77 
    8 use FoswikiFnTestCase; 
     8use FoswikiFnTestCase(); 
    99our @ISA = qw( FoswikiFnTestCase ); 
    1010 
    11 use Unit::Request; 
     11use Foswiki(); 
     12use Foswiki::LoginManager(); 
     13use Unit::Request(); 
    1214use Error qw( :try ); 
    13  
    14 use Foswiki; 
    15 use Foswiki::LoginManager; 
    1615 
    1716my $agent = $Foswiki::cfg{Register}{RegistrationAgentWikiName}; 
     
    2928    my $topicObject = Foswiki::Meta->new( 
    3029        $this->{session},    $this->{test_web}, 
    31         $this->{test_topic}, <<CONSTRAINT); 
     30        $this->{test_topic}, <<'CONSTRAINT'); 
    3231   * Set ALLOWTOPICCHANGE = AdminGroup 
    3332CONSTRAINT 
    3433    $topicObject->save(); 
     34 
     35    return; 
    3536} 
    3637 
    3738sub TemplateLoginManager { 
    3839    $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin'; 
     40 
     41    return; 
    3942} 
    4043 
    4144sub ApacheLoginManager { 
    4245    $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::ApacheLogin'; 
     46 
     47    return; 
    4348} 
    4449 
    4550sub NoLoginManager { 
    4651    $Foswiki::cfg{LoginManager} = 'none'; 
     52 
     53    return; 
    4754} 
    4855 
     
    5158    $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::BaseUserMapping'; 
    5259    $this->set_up_for_verify(); 
     60 
     61    return; 
    5362} 
    5463 
     
    5766    $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping'; 
    5867    $this->set_up_for_verify(); 
     68 
     69    return; 
    5970} 
    6071 
     
    7081    my $this = shift; 
    7182 
    72     $this->{session}->finish() if $this->{session}; 
    73     $this->{session} = new Foswiki( undef, new Unit::Request() ); 
     83    $this->createNewFoswikiSession( undef, Unit::Request->new() ); 
    7484    $this->assert( $Foswiki::cfg{TempfileDir} 
    7585          && -d $Foswiki::cfg{TempfileDir} ); 
     
    8090    $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1; 
    8191    $Foswiki::cfg{UsersWebName} = $this->{users_web}; 
     92 
     93    return; 
    8294} 
    8395 
     
    101113 
    102114#print STDERR "\n------------- set_up_user (login: $userLogin) (cUID:$user_id) -----------------\n"; 
     115 
     116    return; 
    103117} 
    104118 
    105119sub capture { 
    106     my $this = shift; 
    107     my ( $proc, $session ) = @_; 
     120    my ( $this, $proc, $session, @args ) = @_; 
    108121    $session->getLoginManager()->checkAccess(); 
    109     $this->SUPER::capture(@_); 
     122    $this->SUPER::capture( $proc, $session, @args ); 
     123 
     124    return; 
    110125} 
    111126 
     
    118133 
    119134    #close this Foswiki session - its using the wrong mapper and login 
    120     $this->{session}->finish(); 
    121  
    122     $query = new Unit::Request(); 
     135 
     136    $query = Unit::Request->new(); 
    123137    $query->path_info("/$this->{test_web}/$this->{test_topic}"); 
    124     $this->{session} = new Foswiki( undef, $query ); 
     138    $this->createNewFoswikiSession( undef, $query ); 
    125139 
    126140    $this->set_up_user(); 
     
    135149    }; 
    136150 
    137     $query = new Unit::Request(); 
     151    $query = Unit::Request->new(); 
    138152    $query->path_info("/$this->{test_web}/$this->{test_topic}?breaklock=1"); 
    139     $this->{session}->finish(); 
    140  
    141     $this->{session} = new Foswiki( undef, $query ); 
     153 
     154    $this->createNewFoswikiSession( undef, $query ); 
    142155 
    143156    try { 
     
    156169    }; 
    157170 
    158     $query = new Unit::Request(); 
     171    $query = Unit::Request->new(); 
    159172    $query->path_info("/$this->{test_web}/$this->{test_topic}"); 
    160     $this->{session}->finish(); 
    161173 
    162174    $this->annotate("new session using $userLogin\n"); 
    163175 
    164     $this->{session} = new Foswiki( $userLogin, $query ); 
     176    $this->createNewFoswikiSession( $userLogin, $query ); 
    165177 
    166178#clear the lease - one of the previous tests may have different usermapper & thus different user 
    167179    Foswiki::Func::setTopicEditLock( $this->{test_web}, $this->{test_topic}, 
    168180        0 ); 
     181 
     182    return; 
    169183} 
    170184 
     
    175189        return; 
    176190    } 
    177     $this->{session}->finish(); 
    178191    my $secret = "a big mole on my left buttock"; 
    179192    my $crypted = crypt( $secret, "12" ); 
    180193    $Foswiki::cfg{Password} = $crypted; 
    181194 
    182     my $query = new Unit::Request( 
     195    my $query = Unit::Request->new( 
    183196        { 
    184197            username => [ $Foswiki::cfg{AdminUserLogin} ], 
     
    190203    $query->path_info("/$this->{test_web}/$this->{test_topic}"); 
    191204 
    192     $this->{session} = new Foswiki( undef, $query ); 
     205    $this->createNewFoswikiSession( undef, $query ); 
    193206    $this->{session}->getLoginManager()->login( $query, $this->{session} ); 
    194207    my $script = $Foswiki::cfg{LoginManager} =~ /Apache/ ? 'viewauth' : 'view'; 
     
    199212    $this->assert_matches( qr/^$surly/, 
    200213        $this->{session}->{response}->headers()->{Location} ); 
     214 
     215    return; 
    201216} 
    202217 
  • branches/Release01x01/UnitTestContrib/test/unit/ConfigureTests.pm

    r13729 r13794  
    44use warnings; 
    55 
    6 use FoswikiTestCase; 
     6use FoswikiTestCase(); 
    77our @ISA = qw( FoswikiTestCase ); 
    88 
    99use Error qw( :try ); 
    10 use File::Temp; 
     10use File::Temp(); 
    1111use FindBin; 
    1212use File::Path qw(mkpath rmtree); 
     
    3232    $root =~ s|\\|/|g; 
    3333 
    34     $this->{rootdir}  = $root; 
    35     $this->{user}     = $Foswiki::cfg{AdminUserLogin}; 
    36     $this->{session}  = Foswiki->new( $this->{user} ); 
     34    $this->{rootdir} = $root; 
     35    $this->{user}    = $Foswiki::cfg{AdminUserLogin}; 
     36    $this->createNewFoswikiSession( $this->{user} ); 
    3737    $this->{test_web} = 'Testsystemweb1234'; 
    3838    my $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web} ); 
    3939    $webObject->populateNewWeb(); 
     40    $webObject->finish(); 
    4041    $this->{trash_web} = 'Testtrashweb1234'; 
    4142    $webObject = Foswiki::Meta->new( $this->{session}, $this->{trash_web} ); 
    4243    $webObject->populateNewWeb(); 
     44    $webObject->finish(); 
    4345    $this->{sandbox_web} = 'Testsandboxweb1234'; 
    4446    $webObject = Foswiki::Meta->new( $this->{session}, $this->{sandbox_web} ); 
    4547    $webObject->populateNewWeb(); 
     48    $webObject->finish(); 
    4649    $this->{sandbox_subweb} = 'Testsandboxweb1234/Subweb'; 
    4750    $webObject = 
    4851      Foswiki::Meta->new( $this->{session}, $this->{sandbox_subweb} ); 
    4952    $webObject->populateNewWeb(); 
     53    $webObject->finish(); 
    5054    $this->{tempdir} = $Foswiki::cfg{TempfileDir} . '/test_ConfigureTests'; 
    5155    rmtree( $this->{tempdir} ) 
     
    19261930    my ( $result, $err ) = $pkg->loadInstaller(); 
    19271931 
    1928     my $expected = <<HERE; 
     1932    my $expected = <<'HERE'; 
    19291933I can't download http://foswiki.org/pub/Extensions/EmptyPluginx/EmptyPluginx_installer because of the following error: 
    19301934Not Found 
  • branches/Release01x01/UnitTestContrib/test/unit/EmptyTests.pm

    r6912 r13794  
    1 use strict; 
    2  
    31# Example test case; use this as a basis to build your own 
    42 
    53package EmptyTests; 
     4use strict; 
     5use warnings; 
    66 
    77use FoswikiTestCase; 
     
    1010use Foswiki; 
    1111use Error qw( :try ); 
    12  
    13 my $topicquery; 
    1412 
    1513sub set_up { 
     
    2018    # You can now safely modify $Foswiki::cfg 
    2119 
    22     $topicquery = new Unit::Request(''); 
     20    my $topicquery = Unit::Request->new(''); 
    2321    $topicquery->path_info('/TestCases/WebHome'); 
    2422    try { 
    25         $this->{session} = new Foswiki( 'AdminUser' || '' ); 
     23        $this->createNewFoswikiSession( 'AdminUser' || '' ); 
    2624        my $user = $this->{session}->{user}; 
    2725 
     
    3230          Foswiki::Meta->new( $this->{session}, "Temporarytestweb1" ); 
    3331        $webObject->populateNewWeb("_default"); 
     32        $webObject->finish(); 
    3433 
    3534        # Copy a system web like this: 
     
    3736          Foswiki::Meta->new( $this->{session}, "Temporarysystemweb" ); 
    3837        $webObject->populateNewWeb("System"); 
     38        $webObject->finish(); 
    3939 
    4040        # Create a topic like this: 
     
    5252        $this->assert( 0, shift->stringify() || '' ); 
    5353    }; 
     54 
     55    return; 
    5456} 
    5557 
     
    6163    $this->removeWebFixture( $this->{session}, "Temporarytestweb1" ); 
    6264    $this->removeWebFixture( $this->{session}, "Temporarysystemweb" ); 
    63     $this->{session}->finish() if $this->{session}; 
    6465 
    6566    # Always do this, and always do it last 
    6667    $this->SUPER::tear_down(); 
     68 
     69    return; 
    6770} 
    6871 
     
    7780sub test_ { 
    7881    my $this = shift; 
     82 
     83    return; 
    7984} 
    8085 
  • branches/Release01x01/UnitTestContrib/test/unit/ExceptionTests.pm

    r13729 r13794  
    11package ExceptionTests; 
    2 use FoswikiFnTestCase; 
     2use strict; 
     3use warnings; 
     4 
     5use FoswikiFnTestCase(); 
    36our @ISA = qw( FoswikiFnTestCase ); 
    47 
    5 use strict; 
    6  
    78use Error qw( :try ); 
    8 use Foswiki::OopsException; 
    9 use Foswiki::AccessControlException; 
     9use Foswiki::OopsException(); 
     10use Foswiki::AccessControlException(); 
    1011 
    1112my $UI_FN; 
     
    1516    $this->SUPER::set_up(); 
    1617    $UI_FN ||= $this->getUIFn('oops'); 
     18 
     19    return; 
    1720} 
    1821 
     
    4447        ); 
    4548    }; 
     49 
     50    return; 
    4651} 
    4752 
     
    7075        ); 
    7176    }; 
     77 
     78    return; 
    7279} 
    7380 
    7481sub upchuck { 
    7582    my $session = shift; 
    76     my $e       = new Foswiki::OopsException( 
     83    my $e       = Foswiki::OopsException->new( 
    7784        'templatename', 
    7885        web    => 'webname', 
     
    8188    ); 
    8289    $e->redirect($session); 
     90 
     91    return; 
    8392} 
    8493 
     
    8695sub deprecated_test_redirectOopsException { 
    8796    my $this = shift; 
    88     my $t    = new Foswiki(); 
    89     my ($output) = $this->capture( \&upchuck, $t ); 
    90     $t->finish(); 
     97    $this->createNewFoswikiSession(); 
     98    my ($output) = $this->capture( \&upchuck, $this->{session} ); 
    9199    $this->assert_matches( qr/^Status: 302.*$/m, $output ); 
    92100    $this->assert_matches( 
     
    94102        $output 
    95103    ); 
     104 
     105    return; 
    96106} 
    97107 
    98108sub test_AccessControlException { 
    99109    my $this = shift; 
    100     my $ace  = new Foswiki::AccessControlException( 'FRY', 'burger', 'Spiders', 
     110    my $ace  = Foswiki::AccessControlException->new( 'FRY', 'burger', 'Spiders', 
    101111        'FlumpNuts', 'Because it was there.' ); 
    102112    $this->assert_str_equals( 
     
    105115    ); 
    106116 
     117    return; 
    107118} 
    108119 
    109120sub test_oopsScript { 
    110121    my $this  = shift; 
    111     my $query = new Unit::Request( 
     122    my $query = Unit::Request->new( 
    112123        { 
    113124            skin     => 'none', 
     
    121132        } 
    122133    ); 
    123     my $session = new Foswiki( undef, $query ); 
     134    $this->createNewFoswikiSession( undef, $query ); 
    124135    my ($output) = 
    125       $this->capture( $UI_FN, $session, "Flum", "DeDum", $query, 0 ); 
     136      $this->capture( $UI_FN, $this->{session}, "Flum", "DeDum", $query, 0 ); 
    126137    $this->assert_matches( qr/^phlegm$/m,           $output ); 
    127138    $this->assert_matches( qr/^&#60;pus&#62;$/m,    $output ); 
     
    132143    $this->assert_matches( qr/^phlegm$/m,           $output ); 
    133144 
    134     $session->finish(); 
     145    return; 
    135146} 
    136147 
  • branches/Release01x01/UnitTestContrib/test/unit/Fn_GROUPINFO.pm

    r13729 r13794  
     1# tests for the correct expansion of GROUPINFO 
     2 
     3package Fn_GROUPINFO; 
    14use strict; 
    2  
    3 # tests for the correct expansion of GROUPINFO 
    4  
    5 package Fn_GROUPINFO; 
    6  
    7 use FoswikiFnTestCase; 
     5use warnings; 
     6 
     7use FoswikiFnTestCase(); 
    88our @ISA = qw( FoswikiFnTestCase ); 
    99 
    10 use Foswiki; 
     10use Foswiki(); 
     11use Foswiki::Func(); 
    1112use Error qw( :try ); 
    1213 
    1314sub new { 
     15    my ( $class, @args ) = @_; 
     16 
    1417    $Foswiki::cfg{Register}{AllowLoginName} = 1; 
    15     my $self = shift()->SUPER::new( 'GROUPINFO', @_ ); 
    16     return $self; 
     18 
     19    return $class->SUPER::new( 'GROUPINFO', @args ); 
    1720} 
    1821 
     
    2023    my $this = shift; 
    2124    $this->SUPER::set_up(@_); 
    22     my $topicObject = 
    23       Foswiki::Meta->new( $this->{session}, $this->{users_web}, "GropeGroup", 
    24         "   * Set GROUP = ScumBag,WikiGuest\n" ); 
    25     $topicObject->save(); 
    26     $topicObject = 
    27       Foswiki::Meta->new( $this->{session}, $this->{users_web}, "PopGroup", 
    28         "   * Set GROUP = WikiGuest\n" ); 
    29     $topicObject->save(); 
    30     $topicObject = Foswiki::Meta->new( 
    31         $this->{session}, $this->{users_web}, 
    32         "NestingGroup",   "   * Set GROUP = GropeGroup\n" 
    33     ); 
    34     $topicObject->save(); 
    35     $topicObject = 
    36       Foswiki::Meta->new( $this->{session}, $this->{users_web}, 
    37         "OnlyAdminCanChangeGroup", 
    38         "   * Set GROUP = WikiGuest\n   * Set TOPICCHANGE = AdminGroup\n" ); 
    39     $topicObject->save(); 
    40     $topicObject = 
    41       Foswiki::Meta->new( $this->{session}, $this->{users_web}, 
    42         "GroupWithHiddenGroup", "   * Set GROUP = HiddenGroup,WikiGuest\n" ); 
    43     $topicObject->save(); 
    44     $topicObject = 
    45       Foswiki::Meta->new( $this->{session}, $this->{users_web}, "HiddenGroup", 
    46         "   * Set GROUP = ScumBag\n   * Set ALLOWTOPICVIEW = AdminUser\n" ); 
    47     $topicObject->save(); 
    48  
    49     $topicObject = 
    50       Foswiki::Meta->new( $this->{session}, $this->{users_web}, 
    51         "HiddenUserGroup", "   * Set GROUP = ScumBag,HidemeGood\n" ); 
    52     $topicObject->save(); 
    53  
    54     $topicObject = 
    55       Foswiki::Meta->load( $this->{session}, $this->{users_web}, "HidemeGood" ); 
     25    my ($topicObject) = 
     26      Foswiki::Func::readTopic( $this->{users_web}, "GropeGroup" ); 
     27    $topicObject->text("   * Set GROUP = ScumBag,WikiGuest\n"); 
     28    $topicObject->save(); 
     29    $topicObject->finish(); 
     30    ($topicObject) = Foswiki::Func::readTopic( $this->{users_web}, "PopGroup" ); 
     31    $topicObject->text("   * Set GROUP = WikiGuest\n"); 
     32    $topicObject->save(); 
     33    $topicObject->finish(); 
     34    ($topicObject) = 
     35      Foswiki::Func::readTopic( $this->{users_web}, "NestingGroup" ); 
     36    $topicObject->text("   * Set GROUP = GropeGroup\n"); 
     37    $topicObject->save(); 
     38    $topicObject->finish(); 
     39    ($topicObject) = 
     40      Foswiki::Func::readTopic( $this->{users_web}, "OnlyAdminCanChangeGroup" ); 
     41    $topicObject->text( 
     42        "   * Set GROUP = WikiGuest\n   * Set TOPICCHANGE = AdminGroup\n"); 
     43    $topicObject->save(); 
     44    $topicObject->finish(); 
     45    ($topicObject) = 
     46      Foswiki::Func::readTopic( $this->{users_web}, "GroupWithHiddenGroup" ); 
     47    $topicObject->text("   * Set GROUP = HiddenGroup,WikiGuest\n"); 
     48    $topicObject->save(); 
     49    $topicObject->finish(); 
     50    ($topicObject) = 
     51      Foswiki::Func::readTopic( $this->{users_web}, "HiddenGroup" ); 
     52    $topicObject->text( 
     53        "   * Set GROUP = ScumBag\n   * Set ALLOWTOPICVIEW = AdminUser\n"); 
     54    $topicObject->save(); 
     55    $topicObject->finish(); 
     56    ($topicObject) = 
     57      Foswiki::Func::readTopic( $this->{users_web}, "HiddenUserGroup" ); 
     58    $topicObject->text("   * Set GROUP = ScumBag,HidemeGood\n"); 
     59    $topicObject->save(); 
     60    $topicObject->finish(); 
     61    ($topicObject) = 
     62      Foswiki::Func::readTopic( $this->{users_web}, "HidemeGood" ); 
    5663    my $topText = $topicObject->text(); 
    5764    $topText .= "   * Set ALLOWTOPICVIEW = AdminUser\n"; 
    5865    $topText = $topicObject->text($topText); 
    5966    $topicObject->save(); 
    60  
     67    $topicObject->finish(); 
     68 
     69    return; 
    6170} 
    6271 
     
    7079    $this->assert_matches( qr/\bGroupWithHiddenGroup\b/, $ui ); 
    7180    $this->assert_does_not_match( qr/\bHiddenGroup\b/, $ui ); 
     81 
     82    return; 
    7283} 
    7384 
     
    7990    $this->assert_matches( qr/\b$this->{users_web}.ScumBag\b/,   $ui ); 
    8091    $this->assert_matches( qr/\b$this->{users_web}.WikiGuest\b/, $ui ); 
    81     my @u = split( ',', $ui ); 
     92    my @u = split( /,/, $ui ); 
    8293    $this->assert( 2, scalar(@u) ); 
     94 
     95    return; 
    8396} 
    8497 
     
    95108    $this->assert_matches( qr/\b$this->{users_web}.ScumBag\b/,   $ui ); 
    96109    $this->assert_matches( qr/\b$this->{users_web}.WikiGuest\b/, $ui ); 
    97     my @u = split( ',', $ui ); 
     110    my @u = split( /,/, $ui ); 
    98111    $this->assert( 2, scalar(@u) ); 
     112 
     113    return; 
    99114} 
    100115 
     
    107122    $this->assert_matches( qr/\b$this->{users_web}.WikiGuest\b/, $ui ); 
    108123    $this->assert_does_not_match( qr/\b$this->{users_web}.HiddenGroup\b/, $ui ); 
    109     my @u = split( ',', $ui ); 
     124    my @u = split( /,/, $ui ); 
    110125    $this->assert( 1, scalar(@u) ); 
     126 
     127    return; 
    111128} 
    112129 
     
    127144        $ui, 'ScumBag revealed' ); 
    128145 
    129     my @u = split( ',', $ui ); 
     146    my @u = split( /,/, $ui ); 
    130147    $this->assert( 1, scalar(@u) ); 
     148 
     149    return; 
    131150} 
    132151 
     
    141160    $this->assert_does_not_match( qr/\b$this->{users_web}.HidemeGood\b/, 
    142161        $ui, 'HidemeGood revealed' ); 
    143     my @u = split( ',', $ui ); 
     162    my @u = split( /,/, $ui ); 
    144163    $this->assert( 1, scalar(@u) ); 
     164 
     165    return; 
    145166} 
    146167 
     
    148169    my $this = shift; 
    149170 
    150     $this->{session}->finish(); 
    151     $this->{session}          = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
    152     $this->{test_topicObject} = Foswiki::Meta->new( 
    153         $this->{session},    $this->{test_web}, 
    154         $this->{test_topic}, "BLEEGLE\n" 
    155     ); 
     171    $this->createNewFoswikiSession( $Foswiki::cfg{AdminUserLogin} ); 
     172    $this->{test_topicObject}->finish if $this->{test_topicObject}; 
     173    ( $this->{test_topicObject} ) = 
     174      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     175    $this->{test_topicObject}->text("BLEEGLE\n"); 
    156176    $this->{test_topicObject}->save(); 
    157177 
     
    161181    $this->assert_matches( qr/$this->{users_web}.ScumBag/,    $ui ); 
    162182    $this->assert_matches( qr/$this->{users_web}.HidemeGood/, $ui ); 
    163     my @u = split( ',', $ui ); 
     183    my @u = split( /,/, $ui ); 
    164184    $this->assert( 2, scalar(@u) ); 
     185    $this->{test_topicObject}->finish(); 
     186 
     187    return; 
    165188} 
    166189 
     
    201224      ); 
    202225    $this->assert_matches( qr/^<\w+>LF$/, $ui ); 
     226 
     227    return; 
    203228} 
    204229 
  • branches/Release01x01/UnitTestContrib/test/unit/Fn_IF.pm

    r13729 r13794  
    22 
    33package Fn_IF; 
    4  
    54use strict; 
    6  
    7 use FoswikiFnTestCase; 
     5use warnings; 
     6 
     7use FoswikiFnTestCase(); 
    88our @ISA = qw( FoswikiFnTestCase ); 
    99 
    10 use Foswiki; 
     10use Foswiki(); 
    1111use Error qw( :try ); 
    1212use Assert; 
     
    1717 
    1818sub new { 
    19     my $self = shift()->SUPER::new( 'IF', @_ ); 
    20     my $dep = new Foswiki::Configure::Dependency( 
     19    my ( $class, @args ) = @_; 
     20    my $dep = Foswiki::Configure::Dependency->new( 
    2121        type    => "perl", 
    2222        module  => "Foswiki", 
     
    2424    ); 
    2525    ( $post11, my $message ) = $dep->check(); 
    26     return $self; 
     26 
     27    return $class->SUPER::new( 'IF', @args ); 
    2728} 
    2829 
     
    3031    my $this = shift; 
    3132    $this->simpleTest( test => "'A'='B'", then => 0, else => 1 ); 
     33 
     34    return; 
    3235} 
    3336 
     
    3538    my $this = shift; 
    3639    $this->simpleTest( test => "'A'!='B'", then => 1, else => 0 ); 
     40 
     41    return; 
    3742} 
    3843 
     
    4045    my $this = shift; 
    4146    $this->simpleTest( test => "'A'='A'", then => 1, else => 0 ); 
     47 
     48    return; 
    4249} 
    4350 
     
    4552    my $this = shift; 
    4653    $this->simpleTest( test => "'A'='B'", then => 0, else => 1 ); 
     54 
     55    return; 
    4756} 
    4857 
     
    5059    my $this = shift; 
    5160    $this->simpleTest( test => 'context test', then => 1, else => 0 ); 
     61 
     62    return; 
    5263} 
    5364 
     
    5566    my $this = shift; 
    5667    $this->simpleTest( test => 'context \'test\'', then => 1, else => 0 ); 
     68 
     69    return; 
    5770} 
    5871 
     
    6073    my $this = shift; 
    6174    $this->simpleTest( test => "{Fnargle}='Fleeble'", then => 1, else => 0 ); 
     75 
     76    return; 
    6277} 
    6378 
     
    6580    my $this = shift; 
    6681    $this->simpleTest( test => "{A}{B}='C'", then => 1, else => 0 ); 
     82 
     83    return; 
    6784} 
    6885 
     
    7592        else => 0 
    7693    ); 
     94 
     95    return; 
    7796} 
    7897 
     
    85104        else => 0 
    86105    ); 
     106 
     107    return; 
    87108} 
    88109 
     
    92113 
    93114    # See test_96* for other 'defined' tests 
     115 
     116    return; 
    94117} 
    95118 
     
    141164        else => 1 
    142165    ); 
     166 
     167    return; 
    143168} 
    144169 
     
    146171    my $this = shift; 
    147172    $this->simpleTest( test => '0>1', then => 0, else => 1 ); 
     173 
     174    return; 
    148175} 
    149176 
     
    151178    my $this = shift; 
    152179    $this->simpleTest( test => '1>0', then => 1, else => 0 ); 
     180 
     181    return; 
    153182} 
    154183 
     
    156185    my $this = shift; 
    157186    $this->simpleTest( test => '1<0', then => 0, else => 1 ); 
     187 
     188    return; 
    158189} 
    159190 
     
    161192    my $this = shift; 
    162193    $this->simpleTest( test => '0<1', then => 1, else => 0 ); 
     194 
     195    return; 
    163196} 
    164197 
     
    166199    my $this = shift; 
    167200    $this->simpleTest( test => "0>=\t1", then => 0, else => 1 ); 
     201 
     202    return; 
    168203} 
    169204 
     
    171206    my $this = shift; 
    172207    $this->simpleTest( test => '1>=0', then => 1, else => 0 ); 
     208 
     209    return; 
    173210} 
    174211 
     
    176213    my $this = shift; 
    177214    $this->simpleTest( test => '1>=1', then => 1, else => 0 ); 
     215 
     216    return; 
    178217} 
    179218 
     
    181220    my $this = shift; 
    182221    $this->simpleTest( test => '1<=0', then => 0, else => 1 ); 
     222 
     223    return; 
    183224} 
    184225 
     
    186227    my $this = shift; 
    187228    $this->simpleTest( test => '0<=1', then => 1, else => 0 ); 
     229 
     230    return; 
    188231} 
    189232 
     
    191234    my $this = shift; 
    192235    $this->simpleTest( test => '1<=1', then => 1, else => 0 ); 
     236 
     237    return; 
    193238} 
    194239 
     
    196241    my $this = shift; 
    197242    $this->simpleTest( test => "not 'A'='B'", then => 1, else => 0 ); 
     243 
     244    return; 
    198245} 
    199246 
     
    201248    my $this = shift; 
    202249    $this->simpleTest( test => "not NOT 'A'='B'", then => 0, else => 1 ); 
     250 
     251    return; 
    203252} 
    204253 
     
    206255    my $this = shift; 
    207256    $this->simpleTest( test => "'A'='A' AND 'B'='B'", then => 1, else => 0 ); 
     257 
     258    return; 
    208259} 
    209260 
     
    211262    my $this = shift; 
    212263    $this->simpleTest( test => "'A'='A' and 'B'='B'", then => 1, else => 0 ); 
     264 
     265    return; 
    213266} 
    214267 
     
    216269    my $this = shift; 
    217270    $this->simpleTest( test => "'A'='A' and 'B'='B'", then => 1, else => 0 ); 
     271 
     272    return; 
    218273} 
    219274 
     
    225280        else => 0 
    226281    ); 
     282 
     283    return; 
    227284} 
    228285 
     
    230287    my $this = shift; 
    231288    $this->simpleTest( test => "'A'='B' or 'B'='B'", then => 1, else => 0 ); 
     289 
     290    return; 
    232291} 
    233292 
     
    235294    my $this = shift; 
    236295    $this->simpleTest( test => "'A'='A' or 'B'='A'", then => 1, else => 0 ); 
     296 
     297    return; 
    237298} 
    238299 
     
    240301    my $this = shift; 
    241302    $this->simpleTest( test => "'A'='B' or 'B'='A'", then => 0, else => 1 ); 
     303 
     304    return; 
    242305} 
    243306 
     
    249312        else => 0 
    250313    ); 
     314 
     315    return; 
    251316} 
    252317 
     
    258323        else => 0 
    259324    ); 
     325 
     326    return; 
    260327} 
    261328 
     
    263330    my $this = shift; 
    264331    $this->simpleTest( test => "'A'~'B'", then => 0, else => 1 ); 
     332 
     333    return; 
    265334} 
    266335 
     
    268337    my $this = shift; 
    269338    $this->simpleTest( test => "'ABLABA'~'*B?AB*'", then => 1, else => 0 ); 
     339 
     340    return; 
    270341} 
    271342 
     
    273344    my $this = shift; 
    274345    $this->simpleTest( test => '\"BABBA\"~\"*BB?\"', then => 1, else => 0 ); 
     346 
     347    return; 
    275348} 
    276349 
     
    278351    my $this = shift; 
    279352    $this->simpleTest( test => "lc('FRED')='fred'", then => 1, else => 0 ); 
     353 
     354    return; 
    280355} 
    281356 
     
    283358    my $this = shift; 
    284359    $this->simpleTest( test => "('FRED')=uc 'fred'", then => 1, else => 0 ); 
     360 
     361    return; 
    285362} 
    286363 
     
    293370        else => 0 
    294371    ); 
     372 
     373    return; 
    295374} 
    296375 
     
    302381        else => 1 
    303382    ); 
     383 
     384    return; 
    304385} 
    305386 
     
    307388    my $this = shift; 
    308389    $this->simpleTest( test => "1 = 1 > 0", then => 1, else => 0 ); 
     390 
     391    return; 
    309392} 
    310393 
     
    312395    my $this = shift; 
    313396    $this->simpleTest( test => "1 > 1 = 0", then => 1, else => 0 ); 
     397 
     398    return; 
    314399} 
    315400 
     
    317402    my $this = shift; 
    318403    $this->simpleTest( test => "not 1 = 2", then => 1, else => 0 ); 
     404 
     405    return; 
    319406} 
    320407 
     
    322409    my $this = shift; 
    323410    $this->simpleTest( test => "not not 1 and 1", then => 1, else => 0 ); 
     411 
     412    return; 
    324413} 
    325414 
     
    327416    my $this = shift; 
    328417    $this->simpleTest( test => "0 or not not 1 and 1", then => 1, else => 0 ); 
     418 
     419    return; 
    329420} 
    330421 
     
    339430        else => 1 
    340431    ); 
     432 
     433    return; 
    341434} 
    342435 
     
    352445        else => 1 
    353446    ); 
     447 
     448    return; 
    354449} 
    355450 
     
    361456        else => 1 
    362457    ); 
     458 
     459    return; 
    363460} 
    364461 
     
    373470        else => 1 
    374471    ); 
     472 
     473    return; 
    375474} 
    376475 
     
    386485        else => 1 
    387486    ); 
     487 
     488    return; 
    388489} 
    389490 
     
    397498        else => 1 
    398499    ); 
     500 
     501    return; 
    399502} 
    400503 
     
    411514        else => 1 
    412515    ); 
     516 
     517    return; 
    413518} 
    414519 
     
    422527        else => 1 
    423528    ); 
     529 
     530    return; 
    424531} 
    425532 
     
    433540        else => 1 
    434541    ); 
     542 
     543    return; 
    435544} 
    436545 
     
    447556        else => 0 
    448557    ); 
     558 
     559    return; 
    449560} 
    450561 
     
    458569        else => 0 
    459570    ); 
     571 
     572    return; 
    460573} 
    461574 
     
    470583        else => 1 
    471584    ); 
     585 
     586    return; 
    472587} 
    473588 
     
    479594        else => 1 
    480595    ); 
     596 
     597    return; 
    481598} 
    482599 
     
    488605        else => 1 
    489606    ); 
     607 
     608    return; 
    490609} 
    491610 
     
    497616        else => 1 
    498617    ); 
     618 
     619    return; 
    499620} 
    500621 
     
    506627        else => 0 
    507628    ); 
     629 
     630    return; 
    508631} 
    509632 
     
    515638        else => 1 
    516639    ); 
     640 
     641    return; 
    517642} 
    518643 
     
    525650        else => 1 
    526651    ); 
     652 
     653    return; 
    527654} 
    528655 
     
    535662        else => 1 
    536663    ); 
     664 
     665    return; 
    537666} 
    538667 
     
    544673        else => 0 
    545674    ); 
     675 
     676    return; 
    546677} 
    547678 
     
    553684        else => 1 
    554685    ); 
     686 
     687    return; 
    555688} 
    556689 
     
    563696        else => 1 
    564697    ); 
     698 
     699    return; 
    565700} 
    566701 
     
    573708        else => 1 
    574709    ); 
     710 
     711    return; 
    575712} 
    576713 
     
    582719        else => 0 
    583720    ); 
     721 
     722    return; 
    584723} 
    585724 
     
    591730        else => 1 
    592731    ); 
     732 
     733    return; 
    593734} 
    594735 
     
    601742        else => 1 
    602743    ); 
     744 
     745    return; 
    603746} 
    604747 
     
    611754        else => 1 
    612755    ); 
     756 
     757    return; 
    613758} 
    614759 
     
    620765        else => 0 
    621766    ); 
     767 
     768    return; 
    622769} 
    623770 
     
    631778        else => 1 
    632779    ); 
     780 
     781    return; 
    633782} 
    634783 
     
    642791        else => 1 
    643792    ); 
     793 
     794    return; 
    644795} 
    645796 
     
    654805        else => 1 
    655806    ); 
     807 
     808    return; 
    656809} 
    657810 
     
    665818        else => 0 
    666819    ); 
     820 
     821    return; 
    667822} 
    668823 
     
    676831        else => 1 
    677832    ); 
     833 
     834    return; 
    678835} 
    679836 
     
    687844        else => 1 
    688845    ); 
     846 
     847    return; 
    689848} 
    690849 
     
    699858        else => 0 
    700859    ); 
     860 
     861    return; 
    701862} 
    702863 
     
    710871        else => 1 
    711872    ); 
     873 
     874    return; 
    712875} 
    713876 
     
    721884        else => 1 
    722885    ); 
     886 
     887    return; 
    723888} 
    724889 
     
    732897        else => 1 
    733898    ); 
     899 
     900    return; 
    734901} 
    735902 
     
    744911        else => 1 
    745912    ); 
     913 
     914    return; 
    746915} 
    747916 
     
    753922        else => 0 
    754923    ); 
     924 
     925    return; 
    755926} 
    756927 
     
    762933        else => 1 
    763934    ); 
     935 
     936    return; 
    764937} 
    765938 
     
    773946        else => 1 
    774947    ); 
     948 
     949    return; 
    775950} 
    776951 
     
    785960        else => 0 
    786961    ); 
     962 
     963    return; 
    787964} 
    788965 
     
    794971        else => 1 
    795972    ); 
     973 
     974    return; 
    796975} 
    797976 
     
    803982        else => 1 
    804983    ); 
     984 
     985    return; 
    805986} 
    806987 
     
    814995        else => 1 
    815996    ); 
     997 
     998    return; 
    816999} 
    8171000 
     
    8261009        else => 1 
    8271010    ); 
     1011 
     1012    return; 
    8281013} 
    8291014 
     
    8371022        else => 0 
    8381023    ); 
     1024 
     1025    return; 
    8391026} 
    8401027 
     
    8461033        else => 1 
    8471034    ); 
     1035 
     1036    return; 
    8481037} 
    8491038 
     
    8571046        else => 1 
    8581047    ); 
     1048 
     1049    return; 
    8591050} 
    8601051 
     
    8691060        else => 0 
    8701061    ); 
     1062 
     1063    return; 
    8711064} 
    8721065 
     
    8781071        else => 1 
    8791072    ); 
     1073 
     1074    return; 
    8801075} 
    8811076 
     
    8871082        else => 1 
    8881083    ); 
     1084 
     1085    return; 
    8891086} 
    8901087 
     
    8981095        else => 1 
    8991096    ); 
     1097 
     1098    return; 
    9001099} 
    9011100 
     
    9101109        else => 1 
    9111110    ); 
     1111 
     1112    return; 
    9121113} 
    9131114 
     
    9211122        else => 0 
    9221123    ); 
     1124 
     1125    return; 
    9231126} 
    9241127 
     
    9261129    my $this = shift; 
    9271130    $this->simpleTest( test => "isweb 'System'", then => 1, else => 0 ); 
     1131 
     1132    return; 
    9281133} 
    9291134 
     
    9311136    my $this = shift; 
    9321137    $this->simpleTest( test => "isweb 'Not a web'", then => 0, else => 1 ); 
     1138 
     1139    return; 
    9331140} 
    9341141 
     
    9361143    my $this = shift; 
    9371144    $this->simpleTest( test => "istopic \$'System'", then => 0, else => 1 ); 
     1145 
     1146    return; 
    9381147} 
    9391148 
     
    9411150    my $this = shift; 
    9421151    $this->simpleTest( test => "istopic \$'Not a web'", then => 0, else => 1 ); 
     1152 
     1153    return; 
    9431154} 
    9441155 
     
    9501161        else => 1 
    9511162    ); 
     1163 
     1164    return; 
    9521165} 
    9531166 
     
    9591172        else => 1 
    9601173    ); 
     1174 
     1175    return; 
    9611176} 
    9621177 
     
    9681183        else => 1 
    9691184    ); 
     1185 
     1186    return; 
    9701187} 
    9711188 
     
    9771194        else => 1 
    9781195    ); 
     1196 
     1197    return; 
    9791198} 
    9801199 
     
    9821201    my $this = shift; 
    9831202    $this->simpleTest( test => "isweb \$ 'SYSTEMWEB'", then => 1, else => 0 ); 
     1203 
     1204    return; 
    9841205} 
    9851206 
     
    9871208    my $this = shift; 
    9881209    $this->simpleTest( test => 'defined \'SYSTEMWEB\'', then => 1, else => 0 ); 
     1210 
     1211    return; 
    9891212} 
    9901213 
     
    9941217 
    9951218    # see also test_9 and test_96* 
     1219 
     1220    return; 
    9961221} 
    9971222 
     
    9991224    my $this = shift; 
    10001225    $this->simpleTest( test => 'defined( SYSTEMWEB )', then => 1, else => 0 ); 
     1226 
     1227    return; 
    10011228} 
    10021229 
     
    10041231    my $this = shift; 
    10051232    $this->simpleTest( test => "defined( 'SYSTEMWEB' )", then => 1, else => 0 ); 
     1233 
     1234    return; 
    10061235} 
    10071236 
     
    10091238    my $this = shift; 
    10101239    $this->simpleTest( test => 'defined( UNDEF )', then => 0, else => 1 ); 
     1240 
     1241    return; 
    10111242} 
    10121243 
     
    10141245    my $this = shift; 
    10151246    $this->simpleTest( test => "defined( 'UNDEF' )", then => 0, else => 1 ); 
     1247 
     1248    return; 
    10161249} 
    10171250 
     
    10191252    my $this = shift; 
    10201253    $this->simpleTest( test => 'defined \'IF\'', then => 1, else => 0 ); 
     1254 
     1255    return; 
    10211256} 
    10221257 
     
    10241259    my $this = shift; 
    10251260    $this->simpleTest( test => 'defined IF', then => 1, else => 0 ); 
     1261 
     1262    return; 
    10261263} 
    10271264 
     
    10391276        #print STDERR "catched error ".shift."\n"; 
    10401277    }; 
     1278 
     1279    return; 
    10411280} 
    10421281 
     
    10451284    $this->SUPER::set_up(@_); 
    10461285 
    1047     my $topicObject = Foswiki::Meta->new( 
    1048         $this->{session}, 
    1049         $this->{users_web}, 
    1050         "GropeGroup", 
    1051         "   * Set GROUP = " 
    1052           . Foswiki::Func::getWikiName( $this->{session}->{user} ) . "\n" 
    1053     ); 
     1286    my ($topicObject) = 
     1287      Foswiki::Func::readTopic( $this->{users_web}, "GropeGroup" ); 
     1288    $topicObject->text( "   * Set GROUP = " 
     1289          . Foswiki::Func::getWikiName( $this->{session}->{user} ) 
     1290          . "\n" ); 
    10541291    $topicObject->save(); 
     1292    $topicObject->finish(); 
    10551293 
    10561294    # Create WebHome topic to trap existance errors related to 
    10571295    # normalizeWebTopicName 
    1058     $topicObject = Foswiki::Meta->new( 
    1059         $this->{session}, $this->{test_web}, 
    1060         "WebHome",        "Gormless gimboid\n" 
    1061     ); 
     1296    ($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, "WebHome" ); 
     1297    $topicObject->text("Gormless gimboid\n"); 
    10621298    $topicObject->save(); 
     1299    $topicObject->finish(); 
     1300 
     1301    return; 
    10631302} 
    10641303 
     
    10901329    #print STDERR "$text => $result\n"; 
    10911330    $this->assert_equals( '1', $result, $text . " => " . $result ); 
     1331 
     1332    return; 
    10921333} 
    10931334 
     
    10951336    my $this = shift; 
    10961337 
    1097     my $topicObject = 
    1098       Foswiki::Meta->new( $this->{session}, $this->{test_web}, "DeadHerring", 
    1099         <<'SMELL'); 
     1338    my ($topicObject) = 
     1339      Foswiki::Func::readTopic( $this->{test_web}, "DeadHerring" ); 
     1340    $topicObject->text( <<'SMELL'); 
    11001341one %IF{ "defined NAME" then="1" else="0" }% 
    11011342two %IF{ "$ NAME='%NAME%'" then="1" else="0" }% 
     
    11031344SMELL 
    11041345    $topicObject->save(); 
     1346    $topicObject->finish(); 
    11051347    my $text = <<'PONG'; 
    11061348%INCLUDE{"DeadHerring" NAME="Red" warn="on"}% 
     
    11081350    my $result = $this->{test_topicObject}->expandMacros($text); 
    11091351    $this->assert_matches( qr/^\s*one 1\s+two 1\s+three 1\s*$/s, $result ); 
     1352 
     1353    return; 
    11101354} 
    11111355 
     
    11301374        $this->assert_str_equals( $test->{expect}, $result ); 
    11311375    } 
     1376 
     1377    return; 
    11321378} 
    11331379 
     
    11351381    my $this = shift; 
    11361382 
    1137     my $topicObject = 
    1138       Foswiki::Meta->new( $this->{session}, $this->{test_web}, "DeadHerring", 
    1139         <<'SMELL'); 
     1383    my ($topicObject) = 
     1384      Foswiki::Func::readTopic( $this->{test_web}, "DeadHerring" ); 
     1385    $topicObject->text( <<'SMELL'); 
    11401386one %IF{ "BleaghForm.Wibble='Woo'" then="1" else="0" }% 
    11411387%META:FORM{name="BleaghForm"}% 
     
    11431389SMELL 
    11441390    $topicObject->save(); 
     1391    $topicObject->finish(); 
    11451392    my $text = <<'PONG'; 
    11461393%INCLUDE{"DeadHerring" NAME="Red" warn="on"}% 
     
    11481395    my $result = $this->{test_topicObject}->expandMacros($text); 
    11491396    $this->assert_matches( qr/^\s*one 1\s*$/s, $result ); 
     1397 
     1398    return; 
    11501399} 
    11511400 
     
    11531402    my $this = shift; 
    11541403    my $wn   = Foswiki::Func::getWikiName( $this->{session}->{user} ); 
    1155     my $meta = 
    1156       Foswiki::Meta->new( $this->{session}, $this->{test_web}, "DeadDog", 
    1157         <<PONG); 
     1404    my ($meta) = Foswiki::Func::readTopic( $this->{test_web}, "DeadDog" ); 
     1405    $meta->text( <<"PONG"); 
    11581406   * Set ALLOWTOPICVIEW = WibbleFloon 
    11591407   * Set ALLOWTOPICCHANGE = $wn 
    11601408PONG 
    11611409    $meta->save(); 
     1410    $meta->finish(); 
    11621411 
    11631412    my @tests; 
     
    12971546        } 
    12981547    ); 
    1299     $this->{session}->finish(); 
    1300     my $request = new Unit::Request( {} ); 
     1548    my $request = Unit::Request->new( {} ); 
    13011549    $request->path_info("/$this->{test_web}/$this->{test_topic}"); 
    1302     $this->{session} = new Foswiki( undef, $request ); 
    1303     $meta = 
    1304       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    1305         $this->{test_topic} ); 
     1550    $this->createNewFoswikiSession( undef, $request ); 
     1551    ($meta) = 
     1552      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
    13061553 
    13071554    foreach my $test (@tests) { 
     
    13111558            "$text: '$result'" ); 
    13121559    } 
     1560    $meta->finish(); 
     1561 
     1562    return; 
    13131563} 
    13141564 
     
    13181568   * Set LOOP = %IF{"$ LOOP = '1'" then="ping" else="pong"}% 
    13191569PONG 
    1320     my $topicObject = 
    1321       Foswiki::Meta->new( $this->{session}, $this->{test_web}, 
    1322         $this->{test_topic}, $text ); 
     1570    my ($topicObject) = 
     1571      Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 
     1572    $topicObject->text($text); 
    13231573    $topicObject->save(); 
     1574    $topicObject->finish(); 
    13241575    my $result = $this->{test_topicObject}->expandMacros($text); 
    13251576    $this->assert_str_equals( "   * Set LOOP = pong\n", $result ); 
     1577 
     1578    return; 
    13261579} 
    13271580 
     
    13311584    my $topicName = 'TopicInfo'; 
    13321585 
    1333     my $meta = 
    1334       Foswiki::Meta->new( $this->{session}, $this->{test_web}, $topicName, 
    1335         <<PONG); 
     1586    my ($meta) = Foswiki::Func::readTopic( $this->{test_web}, $topicName ); 
     1587    $meta->text( <<'PONG'); 
    13361588oneapeny twoapenny we all fall down 
    13371589PONG 
    13381590    $meta->save(); 
    1339  
    1340     $meta = 
    1341       Foswiki::Meta->load( $this->{session}, $this->{test_web}, $topicName ); 
     1591    $meta->finish(); 
     1592 
     1593    ($meta) = Foswiki::Func::readTopic( $this->{test_web}, $topicName ); 
    13421594    $meta->getRevisionInfo(); 
    13431595    my $ti = $meta->get('TOPICINFO'); 
     
    14081660            "$text: '$result'" ); 
    14091661    } 
     1662    $meta->finish(); 
     1663 
     1664