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/ConfigureTests.pm

    r14 r816  
    33use strict; 
    44 
    5 use base qw(TWikiTestCase); 
     5use base qw(FoswikiTestCase); 
    66 
    77use Error qw( :try ); 
    88use File::Temp; 
    99 
    10 use TWiki::Configure::TWikiCfg; 
    11 use TWiki::Configure::Root; 
    12 use TWiki::Configure::Valuer; 
    13 use TWiki::Configure::UI; 
     10use Foswiki::Configure::FoswikiCfg; 
     11use Foswiki::Configure::Root; 
     12use Foswiki::Configure::Valuer; 
     13use Foswiki::Configure::UI; 
    1414 
    1515# Parse a cfg; change some values; save the changes 
     
    2020    my %cfg = (guff=>"muff"); 
    2121 
    22     my $valuer = new TWiki::Configure::Valuer(\%defaultCfg, \%cfg); 
    23     my $root = new TWiki::Configure::Root(); 
     22    my $valuer = new Foswiki::Configure::Valuer(\%defaultCfg, \%cfg); 
     23    my $root = new Foswiki::Configure::Root(); 
    2424    my ($fh, $fhname) = File::Temp::tempfile(unlink=>1); 
    2525    print $fh <<'EXAMPLE'; 
     
    4545#---+ Three 
    4646# ---++++ Three.1.1.One 
    47 # **SELECTCLASS TWiki::Configure::Types::*** 
    48 $cfg{Types}{Chosen} = 'TWiki::Configure::Types::BOOLEAN'; 
     47# **SELECTCLASS Foswiki::Configure::Types::*** 
     48$cfg{Types}{Chosen} = 'Foswiki::Configure::Types::BOOLEAN'; 
    49491; 
    5050EXAMPLE 
     
    5656    } 
    5757 
    58     TWiki::Configure::TWikiCfg::_parse($fhname, $root, 1); 
     58    Foswiki::Configure::FoswikiCfg::_parse($fhname, $root, 1); 
    5959 
    6060    # nothing should have changed 
    61     my $saver = new TWiki::Configure::TWikiCfg(); 
     61    my $saver = new Foswiki::Configure::FoswikiCfg(); 
    6262    $saver->{valuer} = $valuer; 
    6363    $saver->{root} = $root; 
     
    6969    $cfg{MandatoryPath} = 'fixed'; 
    7070    $cfg{MandatoryBoolean} = 0; 
    71     $cfg{Types}{Chosen} = 'TWiki::Configure::Types::STRING'; 
     71    $cfg{Types}{Chosen} = 'Foswiki::Configure::Types::STRING'; 
    7272    $cfg{OptionalRegex} = qr/^X*$/; 
    7373    $cfg{DontIgnore} = 'now is'; 
     
    7575    $out = $saver->_save(); 
    7676    my $expectacle = <<'EXAMPLE'; 
    77 $TWiki::cfg{MandatoryBoolean} = 0; 
    78 $TWiki::cfg{MandatoryPath} = 'fixed'; 
    79 $TWiki::cfg{OptionalRegex} = '^X*$'; 
    80 $TWiki::cfg{DontIgnore} = 'now is'; 
    81 $TWiki::cfg{Types}{Chosen} = 'TWiki::Configure::Types::STRING'; 
     77$Foswiki::cfg{MandatoryBoolean} = 0; 
     78$Foswiki::cfg{MandatoryPath} = 'fixed'; 
     79$Foswiki::cfg{OptionalRegex} = '^X*$'; 
     80$Foswiki::cfg{DontIgnore} = 'now is'; 
     81$Foswiki::cfg{Types}{Chosen} = 'Foswiki::Configure::Types::STRING'; 
    82821; 
    8383EXAMPLE 
     
    9292sub test_2parse { 
    9393    my $this = shift; 
    94     my $root = new TWiki::Configure::Root(); 
     94    my $root = new Foswiki::Configure::Root(); 
    9595 
    9696    $this->assert_null($root->getValueObject('{One}')); 
     
    100100    print $f1 <<'EXAMPLE'; 
    101101# **STRING 10** 
    102 $TWiki::cfg{One} = 'One'; 
    103 1; 
    104 EXAMPLE 
    105     $f1->close(); 
    106     TWiki::Configure::TWikiCfg::_parse($f1name, $root); 
     102$Foswiki::cfg{One} = 'One'; 
     1031; 
     104EXAMPLE 
     105    $f1->close(); 
     106    Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 
    107107 
    108108    $this->assert_not_null($root->getValueObject('{One}')); 
     
    112112    print $f2 <<'EXAMPLE'; 
    113113# **STRING 10** 
    114 $TWiki::cfg{Two} = 'Two'; 
     114$Foswiki::cfg{Two} = 'Two'; 
    1151151; 
    116116EXAMPLE 
    117117    $f2->close(); 
    118     TWiki::Configure::TWikiCfg::_parse($f2name, $root); 
     118    Foswiki::Configure::FoswikiCfg::_parse($f2name, $root); 
    119119 
    120120    # make sure they are both present 
     
    125125sub test_loadpluggables { 
    126126    my $this = shift; 
    127     my $root = new TWiki::Configure::Root(); 
     127    my $root = new Foswiki::Configure::Root(); 
    128128    my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); 
    129129    print $f1 <<'EXAMPLE'; 
    130130# *LANGUAGES* 
    131131# *PLUGINS* 
    132 $TWiki::cfg{Plugins}{CommentPlugin}{Enabled} = 0; 
    133 1; 
    134 EXAMPLE 
    135     $f1->close(); 
    136     TWiki::Configure::TWikiCfg::_parse($f1name, $root); 
     132$Foswiki::cfg{Plugins}{CommentPlugin}{Enabled} = 0; 
     1331; 
     134EXAMPLE 
     135    $f1->close(); 
     136    Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 
    137137    my $vo = $root->getValueObject('{Plugins}{CommentPlugin}{Enabled}'); 
    138138    $this->assert_not_null($vo); 
     
    147147    my $this = shift; 
    148148 
    149     my $root = new TWiki::Configure::Root(); 
     149    my $root = new Foswiki::Configure::Root(); 
    150150 
    151151    my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); 
     
    153153# **STRING 10** 
    154154# Good description 
    155 $TWiki::cfg{One} = 'One'; 
    156 $TWiki::cfg{Two} = 'One'; 
    157 1; 
    158 EXAMPLE 
    159     $f1->close(); 
    160     TWiki::Configure::TWikiCfg::_parse($f1name, $root); 
     155$Foswiki::cfg{One} = 'One'; 
     156$Foswiki::cfg{Two} = 'One'; 
     1571; 
     158EXAMPLE 
     159    $f1->close(); 
     160    Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 
    161161 
    162162    my $vo = $root->getValueObject('{One}'); 
     
    168168    my ($f2, $f2name) = File::Temp::tempfile(unlink=>1); 
    169169    print $f2 <<'EXAMPLE'; 
    170 $TWiki::cfg{Two} = 'Two'; 
     170$Foswiki::cfg{Two} = 'Two'; 
    171171# **BOOLEAN 10** 
    172172# Bad description 
    173 $TWiki::cfg{One} = 'One'; 
    174 $TWiki::cfg{Three} = 'Three'; 
     173$Foswiki::cfg{One} = 'One'; 
     174$Foswiki::cfg{Three} = 'Three'; 
    1751751; 
    176176EXAMPLE 
    177177    $f2->close(); 
    178     TWiki::Configure::TWikiCfg::_parse($f2name, $root); 
     178    Foswiki::Configure::FoswikiCfg::_parse($f2name, $root); 
    179179 
    180180    $vo = $root->getValueObject('{One}'); 
     
    198198    $cfg{Two} = 'Two'; 
    199199    $cfg{Three} = 'Three'; 
    200     my $valuer = new TWiki::Configure::Valuer(\%defaultCfg, \%cfg); 
    201     my $root = new TWiki::Configure::Root(); 
     200    my $valuer = new Foswiki::Configure::Valuer(\%defaultCfg, \%cfg); 
     201    my $root = new Foswiki::Configure::Root(); 
    202202 
    203203    my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); 
     
    214214EXAMPLE 
    215215    $f1->close(); 
    216     TWiki::Configure::TWikiCfg::_parse($f1name, $root, 1); 
     216    Foswiki::Configure::FoswikiCfg::_parse($f1name, $root, 1); 
    217217    foreach my $k (keys %cfg) { 
    218218        $defaultCfg{$k} = $cfg{$k}; 
     
    221221    $cfg{Two} = 2; 
    222222    $cfg{Three} = 3; 
    223     my $saver = new TWiki::Configure::TWikiCfg(); 
     223    my $saver = new Foswiki::Configure::FoswikiCfg(); 
    224224    $saver->{valuer} = $valuer; 
    225225    $saver->{root} = $root; 
     
    227227    my $out = $saver->_save(); 
    228228    my $expectorate = <<'SPUTUM'; 
    229 $TWiki::cfg{One} = 1; 
    230 $TWiki::cfg{Two} = 2; 
    231 $TWiki::cfg{Three} = 3; 
     229$Foswiki::cfg{One} = 1; 
     230$Foswiki::cfg{Two} = 2; 
     231$Foswiki::cfg{Three} = 3; 
    2322321; 
    233233SPUTUM 
     
    237237sub test_UI { 
    238238    my $this = shift; 
    239     my $root = new TWiki::Configure::Root(); 
     239    my $root = new Foswiki::Configure::Root(); 
    240240    my %defaultCfg = (Value=>"before"); 
    241241    my %cfg = (Value=>"after"); 
    242     my $valuer = new TWiki::Configure::Valuer(\%defaultCfg, \%cfg); 
    243  
    244     my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); 
    245     print $f1 <<'EXAMPLE'; 
    246 # **STRING 10** 
    247 $TWiki::cfg{One} = 'One'; 
    248 # **STRING 10** 
    249 $TWiki::cfg{Two} = 'Two'; 
     242    my $valuer = new Foswiki::Configure::Valuer(\%defaultCfg, \%cfg); 
     243 
     244    my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); 
     245    print $f1 <<'EXAMPLE'; 
     246# **STRING 10** 
     247$Foswiki::cfg{One} = 'One'; 
     248# **STRING 10** 
     249$Foswiki::cfg{Two} = 'Two'; 
    250250# ---+ Plugins 
    251251# *PLUGINS* 
     
    253253EXAMPLE 
    254254    $f1->close(); 
    255     TWiki::Configure::TWikiCfg::_parse($f1name, $root); 
     255    Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 
    256256 
    257257    foreach my $k (keys %cfg) { 
     
    262262    $defaultCfg{One} = "Eno"; 
    263263 
    264     my $ui = TWiki::Configure::UI::loadUI('Root', $root); 
     264    my $ui = Foswiki::Configure::UI::loadUI('Root', $root); 
    265265    my $result = $ui->ui($root, $valuer); 
    266266    # visual check 
     
    269269 
    270270#                print F '| ',gmtime(),' | ',$this->{user},' | ',$txt," |\n"; 
    271 #            if( $TWiki::cfg{ConfigurationLogName} && 
    272 #                  open(F, '>>'.$TWiki::cfg{ConfigurationLogName} )) { 
     271#            if( $Foswiki::cfg{ConfigurationLogName} && 
     272#                  open(F, '>>'.$Foswiki::cfg{ConfigurationLogName} )) { 
    273273#                print F '| ',gmtime(),' | ',$this->{user},' | ',$txt," |\n"; 
    274274#                close(F); 
Note: See TracChangeset for help on using the changeset viewer.