[Rt-commit] r15009 - in rtir/branches/2.3-TESTING/t: . lib/RT lib/RT/IR

ruz at bestpractical.com ruz at bestpractical.com
Mon Aug 11 13:03:17 EDT 2008


Author: ruz
Date: Mon Aug 11 13:03:16 2008
New Revision: 15009

Added:
   rtir/branches/2.3-TESTING/t/lib/
   rtir/branches/2.3-TESTING/t/lib/RT/
   rtir/branches/2.3-TESTING/t/lib/RT/IR/
   rtir/branches/2.3-TESTING/t/lib/RT/IR/Test.pm
Modified:
   rtir/branches/2.3-TESTING/t/001-basic-RTIR.t

Log:
* switch to RT::Test

Modified: rtir/branches/2.3-TESTING/t/001-basic-RTIR.t
==============================================================================
--- rtir/branches/2.3-TESTING/t/001-basic-RTIR.t	(original)
+++ rtir/branches/2.3-TESTING/t/001-basic-RTIR.t	Mon Aug 11 13:03:16 2008
@@ -2,10 +2,12 @@
 
 use strict;
 use warnings;
-use Test::More tests => 21;
 
-require "t/rtir-test.pl";
+BEGIN { require "t/rtir-test.pl" };
+use lib 't/lib';
+use RT::IR::Test tests => 25;
 
+RT::Test->started_ok;
 my $agent = default_agent();
 
 my $SUBJECT = "foo " . rand;

Added: rtir/branches/2.3-TESTING/t/lib/RT/IR/Test.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-TESTING/t/lib/RT/IR/Test.pm	Mon Aug 11 13:03:16 2008
@@ -0,0 +1,65 @@
+use strict;
+use warnings;
+
+package RT::IR::Test;
+use base qw(Test::More);
+use Cwd;
+
+eval 'use RT::Test; 1'
+    or Test::More::plan skip_all => 'requires 3.8 to run tests.  You may need to set PERL5LIB=/path/to/rt/lib';
+
+sub import_extra {
+    my $class = shift;
+    my $args  = shift;
+
+    # Spit out a plan (if we got one) *before* we load modules, in
+    # case of compilation errors
+    $class->builder->plan(@{$args})
+      unless $class->builder->has_plan;
+
+    Test::More->export_to_level(2);
+
+    # Now, clobber Test::Builder::plan (if we got given a plan) so we
+    # don't try to spit one out *again* later.  Test::Builder::Module 
+    # plans for you in import
+    if ($class->builder->has_plan) {
+        no warnings 'redefine';
+        *Test::Builder::plan = sub {};
+    }
+
+    # we need to lie to RT and have it find RTFM's mason templates 
+    # in the local directory
+    {
+        require RT::Plugin;
+        no warnings 'redefine';
+        my $cwd = getcwd;
+        my $old_func = \&RT::Plugin::_BasePath;
+        *RT::Plugin::_BasePath = sub {
+            return $cwd if $_[0]->{name} eq 'RT::IR';
+            return $old_func->(@_);
+        };
+    }
+    RT->Config->Set('Plugins',qw(RT::FM RT::IR));
+    RT->InitPluginPaths;
+
+    {
+        require RT::Plugin;
+        my $rtfm = RT::Plugin->new( name => 'RT::FM' );
+        # RTFM's data
+        my ($ret, $msg) = $RT::Handle->InsertSchema( undef, $rtfm->Path('etc') );
+        Test::More::ok($ret,"Created Schema: ".($msg||''));
+        ($ret, $msg) = $RT::Handle->InsertACL( undef, $rtfm->Path('etc') );
+        Test::More::ok($ret,"Created ACL: ".($msg||''));
+
+        # RTIR's data
+        ($ret, $msg) = $RT::Handle->InsertData('etc/initialdata');
+        Test::More::ok($ret,"Created ACL: ".($msg||''));
+
+        #$RT::Handle->Connect;
+    }
+
+    RT->Config->LoadConfig( File => 'RTIR_Config.pm' );
+    RT->Config->Set( 'rtirname' => 'regression_tests' );
+}
+
+1;


More information about the Rt-commit mailing list