Ignore:
Timestamp:
11/19/08 19:11:33 (4 years ago)
Author:
CrawfordCurrie
Message:

Item175: ported unit tests to new namespace. They all pass.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UnitTestContrib/test/unit/ClientTests.pm

    r672 r816  
    66# LoginManager.pm compiles okay. 
    77 
    8 use base qw(TWikiFnTestCase); 
     8use base qw(FoswikiFnTestCase); 
    99 
    1010use Unit::Request; 
    1111use Error qw( :try ); 
    1212 
    13 use TWiki; 
    14 use TWiki::LoginManager; 
    15 use TWiki::UI::View; 
    16 use TWiki::UI::Edit; 
     13use Foswiki; 
     14use Foswiki::LoginManager; 
     15use Foswiki::UI::View; 
     16use Foswiki::UI::Edit; 
    1717 
    18 my $agent = $TWiki::cfg{Register}{RegistrationAgentWikiName}; 
     18my $agent = $Foswiki::cfg{Register}{RegistrationAgentWikiName}; 
    1919my $userLogin; 
    2020my $userWikiName; 
     
    3232 
    3333sub TemplateLoginManager { 
    34     $TWiki::cfg{LoginManager} = 'TWiki::LoginManager::TemplateLogin'; 
     34    $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin'; 
    3535} 
    3636 
    3737sub ApacheLoginManager { 
    38     $TWiki::cfg{LoginManager} = 'TWiki::LoginManager::ApacheLogin'; 
     38    $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::ApacheLogin'; 
    3939} 
    4040 
    4141sub NoLoginManager { 
    42     $TWiki::cfg{LoginManager} = 'none'; 
     42    $Foswiki::cfg{LoginManager} = 'none'; 
    4343} 
    4444 
    4545sub BaseUserMapping { 
    4646    my $this = shift; 
    47     $TWiki::cfg{UserMappingManager} = 'TWiki::Users::BaseUserMapping'; 
     47    $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::BaseUserMapping'; 
    4848    $this->set_up_for_verify(); 
    4949} 
     
    5151sub TopicUserMapping { 
    5252    my $this = shift; 
    53     $TWiki::cfg{UserMappingManager} = 'TWiki::Users::TopicUserMapping'; 
     53    $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping'; 
    5454    $this->set_up_for_verify(); 
    5555} 
     
    6767 
    6868    $this->{twiki}->finish() if $this->{twiki}; 
    69     $this->{twiki} = new TWiki(undef, new Unit::Request()); 
    70     $this->assert($TWiki::cfg{TempfileDir} && -d $TWiki::cfg{TempfileDir}); 
    71     $TWiki::cfg{UseClientSessions} = 1; 
    72     $TWiki::cfg{PasswordManager} = "TWiki::Users::HtPasswdUser"; 
    73     $TWiki::cfg{Htpasswd}{FileName} = "$TWiki::cfg{TempfileDir}/htpasswd"; 
    74     $TWiki::cfg{AuthScripts} = "edit"; 
    75     $TWiki::cfg{Register}{EnableNewUserRegistration} = 1; 
    76     $TWiki::cfg{UsersWebName} = $this->{users_web}; 
     69    $this->{twiki} = new Foswiki(undef, new Unit::Request()); 
     70    $this->assert($Foswiki::cfg{TempfileDir} && -d $Foswiki::cfg{TempfileDir}); 
     71    $Foswiki::cfg{UseClientSessions} = 1; 
     72    $Foswiki::cfg{PasswordManager} = "Foswiki::Users::HtPasswdUser"; 
     73    $Foswiki::cfg{Htpasswd}{FileName} = "$Foswiki::cfg{TempfileDir}/htpasswd"; 
     74    $Foswiki::cfg{AuthScripts} = "edit"; 
     75    $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1; 
     76    $Foswiki::cfg{UsersWebName} = $this->{users_web}; 
    7777} 
    7878 
     
    8585            $this->annotate("create $userLogin user - cUID = $user_id\n"); 
    8686    } else { 
    87         $userLogin = $TWiki::cfg{AdminUserLogin}; 
     87        $userLogin = $Foswiki::cfg{AdminUserLogin}; 
    8888        $user_id = $this->{twiki}->{users}->getCanonicalUserID($userLogin); 
    8989        $userWikiName = $this->{twiki}->{users}->getWikiName($user_id); 
     
    106106    my ( $query, $text ); 
    107107 
    108     #close this TWiki session - its using the wrong mapper and login 
     108    #close this Foswiki session - its using the wrong mapper and login 
    109109    $this->{twiki}->finish(); 
    110110 
    111111    $query = new Unit::Request(); 
    112112    $query->path_info( "/$this->{test_web}/$this->{test_topic}" ); 
    113     $this->{twiki} = new TWiki( undef, $query ); 
     113    $this->{twiki} = new Foswiki( undef, $query ); 
    114114 
    115115    $this->set_up_user(); 
    116116    try { 
    117         $text = $this->capture( \&TWiki::UI::View::view, $this->{twiki} ); 
    118     } catch TWiki::OopsException with { 
     117        $text = $this->capture( \&Foswiki::UI::View::view, $this->{twiki} ); 
     118    } catch Foswiki::OopsException with { 
    119119        $this->assert(0,shift->stringify()); 
    120120    } catch Error::Simple with { 
     
    126126    $this->{twiki}->finish(); 
    127127 
    128     $this->{twiki} = new TWiki( undef, $query ); 
     128    $this->{twiki} = new Foswiki( undef, $query ); 
    129129 
    130130    try { 
    131         $text = $this->capture( \&TWiki::UI::Edit::edit, $this->{twiki} ); 
    132     } catch TWiki::AccessControlException with { 
     131        $text = $this->capture( \&Foswiki::UI::Edit::edit, $this->{twiki} ); 
     132    } catch Foswiki::AccessControlException with { 
    133133    } catch Error::Simple with { 
    134134        $this->assert(0,shift->stringify()); 
    135135    } otherwise { 
    136         unless( $TWiki::cfg{LoginManager} eq 'none' ) { 
     136        unless( $Foswiki::cfg{LoginManager} eq 'none' ) { 
    137137            $this->assert(0, "expected an access control exception: ". 
    138                             $TWiki::cfg{LoginManager}."\n$text"); 
     138                            $Foswiki::cfg{LoginManager}."\n$text"); 
    139139        } 
    140140    }; 
     
    146146    $this->annotate("new session using $userLogin\n"); 
    147147 
    148     $this->{twiki} = new TWiki( $userLogin, $query ); 
     148    $this->{twiki} = new Foswiki( $userLogin, $query ); 
    149149 
    150150    #clear the lease - one of the previous tests may have different usermapper & thus different user 
    151     TWiki::Func::setTopicEditLock($this->{test_web}, $this->{test_topic}, 0); 
     151    Foswiki::Func::setTopicEditLock($this->{test_web}, $this->{test_topic}, 0); 
    152152} 
    153153 
     
    161161    my $secret = "a big mole on my left buttock"; 
    162162    my $crypted = crypt($secret, "12"); 
    163     $TWiki::cfg{Password} = $crypted; 
     163    $Foswiki::cfg{Password} = $crypted; 
    164164 
    165165    my $query = new Unit::Request({ 
    166         username => [ $TWiki::cfg{AdminUserLogin} ], 
     166        username => [ $Foswiki::cfg{AdminUserLogin} ], 
    167167        password => [ $secret ], 
    168168        Logon => [ 1 ], 
     
    171171    $query->path_info( "/$this->{test_web}/$this->{test_topic}" ); 
    172172 
    173     $this->{twiki} = new TWiki(undef, $query); 
     173    $this->{twiki} = new Foswiki(undef, $query); 
    174174    my ($text, $result) = $this->capture( 
    175175        sub { 
Note: See TracChangeset for help on using the changeset viewer.