new config option to DBICTest to let you set an alternative storage type, start on...
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest.pm
index 27c8549..2077af3 100755 (executable)
@@ -29,6 +29,7 @@ DBIx::Class.
   my $schema = DBICTest->init_schema(
     no_deploy=>1,
     no_populate=>1,
+    storage_type=>'::DBI::Replicated',
   );
 
 This method removes the test SQLite database in t/var/DBIxClass.db 
@@ -42,9 +43,8 @@ default, unless the no_deploy or no_populate flags are set.
 
 =cut
 
-sub init_schema {
+sub _database {
     my $self = shift;
-    my %args = @_;
     my $db_file = "t/var/DBIxClass.db";
 
     unlink($db_file) if -e $db_file;
@@ -55,13 +55,31 @@ sub init_schema {
     my $dbuser = $ENV{"DBICTEST_DBUSER"} || '';
     my $dbpass = $ENV{"DBICTEST_DBPASS"} || '';
 
-    my $compose_method = ($args{compose_connection}
-                           ? 'compose_connection'
-                           : 'compose_namespace');
+    my @connect_info = ($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
+
+    return @connect_info;
+}
 
-    my $schema = DBICTest::Schema->$compose_method('DBICTest')
-                                 ->connect($dsn, $dbuser, $dbpass);
-    $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']);
+sub init_schema {
+    my $self = shift;
+    my %args = @_;
+
+    my $schema;
+
+    if ($args{compose_connection}) {
+      $schema = DBICTest::Schema->compose_connection(
+                  'DBICTest', $self->_database
+                );
+    } else {
+      $schema = DBICTest::Schema->compose_namespace('DBICTest');
+    }
+    if( $args{storage_type}) {
+       $schema->storage_type($args{storage_type});
+    }
+    if ( !$args{no_connect} ) {
+      $schema = $schema->connect($self->_database);
+      $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']);
+    }
     if ( !$args{no_deploy} ) {
         __PACKAGE__->deploy_schema( $schema );
         __PACKAGE__->populate_schema( $schema ) if( !$args{no_populate} );