[Rt-commit] r18778 - rt/3.999/branches/config-in-db/lib/RT

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Mar 13 04:00:16 EDT 2009


Author: sunnavy
Date: Fri Mar 13 04:00:16 2009
New Revision: 18778

Modified:
   rt/3.999/branches/config-in-db/lib/RT/Test.pm

Log:
rewrite config part in Test.pm to make tests happy

Modified: rt/3.999/branches/config-in-db/lib/RT/Test.pm
==============================================================================
--- rt/3.999/branches/config-in-db/lib/RT/Test.pm	(original)
+++ rt/3.999/branches/config-in-db/lib/RT/Test.pm	Fri Mar 13 04:00:16 2009
@@ -73,7 +73,7 @@
 
 my $config;
 our ( $existing_server, $port );
-my $mailsent;
+our $MAIL_SENT;
 
 my @server;
 
@@ -119,32 +119,23 @@
     my %args  = (@_);
 
     require RT;
-    RT->load_config();
-    my $port = 999;
-    $config = File::Temp->new;
-    print $config qq{
-set( \$WebPort , $port);
-set( \$WebbaseURL , "http://localhost:\$WebPort");
-set( \$LogToScreen , "debug");
-set( \$LogStackTraces , "warning");
-set( \$MailCommand, 'testfile' );
-};
-    print $config $args{'config'} if $args{'config'};
-    print $config "\n1;\n";
-    $ENV{'RT_SITE_CONFIG'} = $config->filename;
-    close $config;
+    RT->config->set( web_port => $port );
+    RT->config->set( web_base_url => "http://localhost:$port" );
+    RT->config->set( log_to_screen => 'debug' );
+    RT->config->set( log_stack_traces => 'warning' );
+    RT->config->set( mail_command => 'testfile' );
 
-    RT->config->set( DevelMode => '0' ) if $INC{'Devel/Cover.pm'};
-    if ( RT->config->get('DevelMode') ) { require Module::Refresh; }
+    Jifty->config->{'framework'}{'DevelMode'} = 0 if $INC{'Devel/Cover.pm'};
+    if ( Jifty->config->framework('DevelMode') ) { require Module::Refresh; }
 
     # make it another function
-    $mailsent = 0;
+    $MAIL_SENT = 0;
     my $mailfunc = sub {
         my $Entity = shift;
-        $mailsent++;
+        $RT::Test::MAIL_SENT++;
         return 1;
     };
-    RT->config->set( 'MailCommand' => $mailfunc );
+    RT->config->set( 'mail_command' => $mailfunc );
 }
 our $server_url;
 
@@ -181,7 +172,7 @@
 sub mailsent_ok {
     my $class    = shift;
     my $expected = shift;
-    is( $mailsent, $expected, "The number of mail sent ($expected) matches. yay" );
+    is( $MAIL_SENT, $expected, "The number of mail sent ($expected) matches. yay" );
 }
 
 =head1 UTILITIES
@@ -538,15 +529,15 @@
     );
 }
 
-my $mailbox_catcher = File::Temp->new( OPEN => 0, CLEANUP => 0 )->filename;
+our $MAILBOX_CATCHER = File::Temp->new( OPEN => 0, CLEANUP => 0 )->filename;
 
 sub set_mail_catcher {
     my $self    = shift;
     my $catcher = sub {
         my $MIME = shift;
 
-        open my $handle, '>>', $mailbox_catcher
-          or die "Unable to open $mailbox_catcher for appending: $!";
+        open my $handle, '>>', $RT::TEST::MAILBOX_CATCHER
+          or die "Unable to open $MAILBOX_CATCHER for appending: $!";
 
         $MIME->print($handle);
         print $handle "%% split me! %%\n";
@@ -565,11 +556,11 @@
 sub fetch_caught_mails {
     my $self = shift;
     return grep /\S/, split /%% split me! %%/,
-       RT::Test->file_content( $mailbox_catcher, 'unlink' => 1, noexist => 1 );
+       RT::Test->file_content( $MAILBOX_CATCHER, 'unlink' => 1, noexist => 1 );
 }
 
 sub clean_caught_mails {
-    unlink $mailbox_catcher;
+    unlink $MAILBOX_CATCHER;
 }
 
 sub file_content {
@@ -616,7 +607,7 @@
     require RT::Crypt::GnuPG;
     require GnuPG::Interface;
     my $gnupg = new GnuPG::Interface;
-    my %opt   = RT->config->get('GnuPGOptions');
+    my %opt   = %{RT->config->get('GnuPGOptions')};
     $gnupg->options->hash_init( RT::Crypt::GnuPG::_prepare_gnupg_options(%opt), meta_interactive => 0, );
 
     my %handle;
@@ -674,7 +665,7 @@
     require RT::Crypt::GnuPG;
     require GnuPG::Interface;
     my $gnupg = new GnuPG::Interface;
-    my %opt   = RT->config->get('GnuPGOptions');
+    my %opt   = %{RT->config->get('GnuPGOptions')};
     $gnupg->options->hash_init( RT::Crypt::GnuPG::_prepare_gnupg_options(%opt), meta_interactive => 0, );
 
     my %handle;


More information about the Rt-commit mailing list