X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest.pm;h=5c76153f267bf0633d72b45c9f0921159cb9828c;hb=a0024650c5dfd609c73a3ec954ba13c67870af3f;hp=8f1521cb0cf0de7a9949558a85591b43b3d7f5be;hpb=77d76d0f2fe3f253eea0fb2b4b1f0f604d130d9e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 8f1521c..5c76153 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -42,9 +42,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 +54,28 @@ 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; +} + +sub init_schema { + my $self = shift; + my %args = @_; + + my $schema; - my $schema = DBICTest::Schema->$compose_method('DBICTest') - ->connect($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); - $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']); + if ($args{compose_connection}) { + $schema = DBICTest::Schema->compose_connection( + 'DBICTest', $self->_database + ); + } else { + $schema = DBICTest::Schema->compose_namespace('DBICTest'); + } + 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} );