Ignore:
Timestamp:
12/13/08 16:58:36 (3 years ago)
Author:
CrawfordCurrie
Message:

Item456: work in progress

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MailInContrib/test/unit/MailInContrib/MailInContribSuite.pm

    r1064 r1323  
    22 
    33package MailInContribSuite; 
    4  
    5 use base qw( FoswikiFnTestCase! ); 
    6  
    7 use TWiki; 
     4use base 'FoswikiFnTestCase'; 
     5 
     6use Foswiki; 
    87use Error qw( :try ); 
    98use File::Path; 
    109use Error qw( :try ); 
    11 use TWiki::Contrib::MailInContrib; 
     10use Foswiki::Contrib::MailInContrib; 
    1211 
    1312my $box; 
     
    2322    $this->{twiki}->{store}->createWeb( 
    2423        $this->{twiki}->{user}, $this->{system_web}, 
    25         $TWiki::cfg{SystemWebName} ); 
     24        $Foswiki::cfg{SystemWebName} ); 
     25    my $adm = Foswiki::Func::getCanonicalUserID( 
     26        $Foswiki::cfg{AdminUserWikiName}); 
    2627    $this->{twiki}->{store}->saveTopic( 
    27         $TWiki::cfg{AdminUserWikiName}, $this->{system_web}, 
     28        $adm, $this->{system_web}, 
    2829        'WebPreferences', ""); 
    2930 
    30     $TWiki::cfg{SystemWebName} = $this->{system_web}; 
     31    $Foswiki::cfg{SystemWebName} = $this->{system_web}; 
    3132 
    3233    $this->{twiki}->finish(); 
    33     $this->{twiki} = new TWiki(); 
    34  
    35     my $workdir = TWiki::Func::getWorkArea('MailInContrib'); 
     34    $this->{twiki} = new Foswiki(); 
     35 
     36    my $workdir = Foswiki::Func::getWorkArea('MailInContrib'); 
    3637    open(F, ">$workdir/timestamp") || die $!; 
    3738    print F "0\n"; 
     
    5051 
    5152    $this->{twiki}->finish(); 
    52     $this->{twiki} = new TWiki(); 
     53    $this->{twiki} = new Foswiki(); 
    5354    $this->{twiki}->net->setMailHandler(\&sentMail); 
    5455 
    5556    $box = {}; 
    56  
    5757    # Make a maildir 
    5858    my $tmp = "/tmp/mail$$"; 
     
    6262    $box->{folder} = "$tmp/"; 
    6363 
    64     $TWiki::cfg{MailInContrib} = [ $box ]; 
     64    $Foswiki::cfg{MailInContrib} = [ $box ]; 
    6565    @mails = (); 
    6666} 
     
    9494sub cron { 
    9595    my $this = shift; 
    96     my $min = new TWiki::Contrib::MailInContrib( $this->{twiki}, 0 ); 
     96    my $min = new Foswiki::Contrib::MailInContrib( $this->{twiki}, 0 ); 
    9797    $min->processInbox( $box ); 
    9898    $min->wrapUp(); 
     
    119119and there is no valid default username', $c->{error}); 
    120120 
    121     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
     121    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
    122122 
    123123    $this->assert($t !~ /\S/, $t); 
     
    154154    $this->assert_null($c->{error}); 
    155155 
    156     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
     156    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
    157157 
    158158    $this->assert($t =~ s/^ *\* \*$this->{test_web}\.NotHere\*: Message 1 text here\s*-- $this->{users_web}\.MoleInnaHole -\s+\d+\s+\w+\s+\d+\s+-\s+\d+:\d+\n//m, $t); 
     
    190190    $this->assert_null($c->{error}); 
    191191 
    192     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
     192    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
    193193 
    194194    $this->assert($t =~ s/^\s*\* \*\*: Message 1 text here\s* -- $this->{users_web}\.MoleInnaHole -\s+\d+\s+\w+\s+\d+\s+-\s+\d+:\d+$//m, $t); 
     
    223223    $this->assert_null($c->{error}); 
    224224 
    225     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},'DangleBerries'); 
     225    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},'DangleBerries'); 
    226226 
    227227    $t =~ s/\* \*no valid topic\*: Message 1 text here\s*-- $this->{users_web}.AllyGator -\s+\d+\s+\w+\s+\d+\s+-\s+\d+:\d+//s; 
     
    367367    my $c = $this->cron(); 
    368368 
     369print STDERR "VBLO\n"; 
    369370    $this->assert_equals(1, scalar(@mails)); 
    370371    $this->assert_matches(qr/Thank you for your successful/, $mails[0]); 
    371372 
    372     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},'AnotherTopic'); 
     373    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},'AnotherTopic'); 
    373374    my @a = $m->get('FILEATTACHMENT'); 
    374375    $this->assert_equals(1, scalar(@a)); 
    375376    $this->assert_str_equals("data.asc", $a[0]->{attachment}); 
    376377 
    377     $this->assert(-e "$TWiki::cfg{PubDir}/$this->{test_web}/AnotherTopic/data.asc"); 
     378    $this->assert(-e "$Foswiki::cfg{PubDir}/$this->{test_web}/AnotherTopic/data.asc"); 
    378379} 
    379380 
     
    395396    $box->{onSuccess} = 'reply delete'; 
    396397    $this->{twiki}->{store}->saveTopic( 
    397         $this->{twiki}->{user}, $TWiki::cfg{SystemWebName}, 
     398        $this->{twiki}->{user}, $Foswiki::cfg{SystemWebName}, 
    398399        'MailInContribUserTemplate', <<'HERE'); 
    399400%TMPL:DEF{MAILIN:wierd}% 
     
    414415    $this->assert_matches(qr/Thank you for your successful/, $mails[0]); 
    415416 
    416     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},'TargetTopic'); 
     417    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},'TargetTopic'); 
    417418 
    418419    $this->assert_matches(qr/BEGIN\s*Subject: Object\s*Body: Message 1 text here\s*<!--MAIL{/s, $t); 
Note: See TracChangeset for help on using the changeset viewer.