Changeset 816 for trunk/UnitTestContrib/test/unit/ConfigureTests.pm
- Timestamp:
- 11/19/08 19:11:33 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UnitTestContrib/test/unit/ConfigureTests.pm
r14 r816 3 3 use strict; 4 4 5 use base qw( TWikiTestCase);5 use base qw(FoswikiTestCase); 6 6 7 7 use Error qw( :try ); 8 8 use File::Temp; 9 9 10 use TWiki::Configure::TWikiCfg;11 use TWiki::Configure::Root;12 use TWiki::Configure::Valuer;13 use TWiki::Configure::UI;10 use Foswiki::Configure::FoswikiCfg; 11 use Foswiki::Configure::Root; 12 use Foswiki::Configure::Valuer; 13 use Foswiki::Configure::UI; 14 14 15 15 # Parse a cfg; change some values; save the changes … … 20 20 my %cfg = (guff=>"muff"); 21 21 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(); 24 24 my ($fh, $fhname) = File::Temp::tempfile(unlink=>1); 25 25 print $fh <<'EXAMPLE'; … … 45 45 #---+ Three 46 46 # ---++++ 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'; 49 49 1; 50 50 EXAMPLE … … 56 56 } 57 57 58 TWiki::Configure::TWikiCfg::_parse($fhname, $root, 1);58 Foswiki::Configure::FoswikiCfg::_parse($fhname, $root, 1); 59 59 60 60 # nothing should have changed 61 my $saver = new TWiki::Configure::TWikiCfg();61 my $saver = new Foswiki::Configure::FoswikiCfg(); 62 62 $saver->{valuer} = $valuer; 63 63 $saver->{root} = $root; … … 69 69 $cfg{MandatoryPath} = 'fixed'; 70 70 $cfg{MandatoryBoolean} = 0; 71 $cfg{Types}{Chosen} = ' TWiki::Configure::Types::STRING';71 $cfg{Types}{Chosen} = 'Foswiki::Configure::Types::STRING'; 72 72 $cfg{OptionalRegex} = qr/^X*$/; 73 73 $cfg{DontIgnore} = 'now is'; … … 75 75 $out = $saver->_save(); 76 76 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'; 82 82 1; 83 83 EXAMPLE … … 92 92 sub test_2parse { 93 93 my $this = shift; 94 my $root = new TWiki::Configure::Root();94 my $root = new Foswiki::Configure::Root(); 95 95 96 96 $this->assert_null($root->getValueObject('{One}')); … … 100 100 print $f1 <<'EXAMPLE'; 101 101 # **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'; 103 1; 104 EXAMPLE 105 $f1->close(); 106 Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 107 107 108 108 $this->assert_not_null($root->getValueObject('{One}')); … … 112 112 print $f2 <<'EXAMPLE'; 113 113 # **STRING 10** 114 $ TWiki::cfg{Two} = 'Two';114 $Foswiki::cfg{Two} = 'Two'; 115 115 1; 116 116 EXAMPLE 117 117 $f2->close(); 118 TWiki::Configure::TWikiCfg::_parse($f2name, $root);118 Foswiki::Configure::FoswikiCfg::_parse($f2name, $root); 119 119 120 120 # make sure they are both present … … 125 125 sub test_loadpluggables { 126 126 my $this = shift; 127 my $root = new TWiki::Configure::Root();127 my $root = new Foswiki::Configure::Root(); 128 128 my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); 129 129 print $f1 <<'EXAMPLE'; 130 130 # *LANGUAGES* 131 131 # *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; 133 1; 134 EXAMPLE 135 $f1->close(); 136 Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 137 137 my $vo = $root->getValueObject('{Plugins}{CommentPlugin}{Enabled}'); 138 138 $this->assert_not_null($vo); … … 147 147 my $this = shift; 148 148 149 my $root = new TWiki::Configure::Root();149 my $root = new Foswiki::Configure::Root(); 150 150 151 151 my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); … … 153 153 # **STRING 10** 154 154 # 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'; 157 1; 158 EXAMPLE 159 $f1->close(); 160 Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 161 161 162 162 my $vo = $root->getValueObject('{One}'); … … 168 168 my ($f2, $f2name) = File::Temp::tempfile(unlink=>1); 169 169 print $f2 <<'EXAMPLE'; 170 $ TWiki::cfg{Two} = 'Two';170 $Foswiki::cfg{Two} = 'Two'; 171 171 # **BOOLEAN 10** 172 172 # Bad description 173 $ TWiki::cfg{One} = 'One';174 $ TWiki::cfg{Three} = 'Three';173 $Foswiki::cfg{One} = 'One'; 174 $Foswiki::cfg{Three} = 'Three'; 175 175 1; 176 176 EXAMPLE 177 177 $f2->close(); 178 TWiki::Configure::TWikiCfg::_parse($f2name, $root);178 Foswiki::Configure::FoswikiCfg::_parse($f2name, $root); 179 179 180 180 $vo = $root->getValueObject('{One}'); … … 198 198 $cfg{Two} = 'Two'; 199 199 $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(); 202 202 203 203 my ($f1, $f1name) = File::Temp::tempfile(unlink=>1); … … 214 214 EXAMPLE 215 215 $f1->close(); 216 TWiki::Configure::TWikiCfg::_parse($f1name, $root, 1);216 Foswiki::Configure::FoswikiCfg::_parse($f1name, $root, 1); 217 217 foreach my $k (keys %cfg) { 218 218 $defaultCfg{$k} = $cfg{$k}; … … 221 221 $cfg{Two} = 2; 222 222 $cfg{Three} = 3; 223 my $saver = new TWiki::Configure::TWikiCfg();223 my $saver = new Foswiki::Configure::FoswikiCfg(); 224 224 $saver->{valuer} = $valuer; 225 225 $saver->{root} = $root; … … 227 227 my $out = $saver->_save(); 228 228 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; 232 232 1; 233 233 SPUTUM … … 237 237 sub test_UI { 238 238 my $this = shift; 239 my $root = new TWiki::Configure::Root();239 my $root = new Foswiki::Configure::Root(); 240 240 my %defaultCfg = (Value=>"before"); 241 241 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'; 250 250 # ---+ Plugins 251 251 # *PLUGINS* … … 253 253 EXAMPLE 254 254 $f1->close(); 255 TWiki::Configure::TWikiCfg::_parse($f1name, $root);255 Foswiki::Configure::FoswikiCfg::_parse($f1name, $root); 256 256 257 257 foreach my $k (keys %cfg) { … … 262 262 $defaultCfg{One} = "Eno"; 263 263 264 my $ui = TWiki::Configure::UI::loadUI('Root', $root);264 my $ui = Foswiki::Configure::UI::loadUI('Root', $root); 265 265 my $result = $ui->ui($root, $valuer); 266 266 # visual check … … 269 269 270 270 # 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} )) { 273 273 # print F '| ',gmtime(),' | ',$this->{user},' | ',$txt," |\n"; 274 274 # close(F);
Note: See TracChangeset
for help on using the changeset viewer.
