1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
package # hide from PAUSE
DBIx::Class::Schema::PopulateMore::Test::Schema;
use Path::Class;
use parent 'DBIx::Class::Schema';
=head1 NAME
DBIx::Class::Schema::PopulateMore::Test::Schema - Test Schema
=head1 DESCRIPTION
Defines the base case for loading DBIC Schemas. This schema currently defines
three sources, Person, FriendList, and Gender
=head1 PACKAGE METHODS
The following is a list of package methods declared with this class.
=head2 load_components
Load the components
=cut
__PACKAGE__->load_components(qw/
Schema::PopulateMore
/);
=head2 load_namespaces
Automatically load the classes and resultsets from their default namespaces.
=cut
__PACKAGE__->load_namespaces(
default_resultset_class => 'ResultSet',
);
=head1 ATTRIBUTES
This class defines the following attributes.
=head1 METHODS
This module declares the following methods
=head2 connect_and_setup
Creates a schema, deploys a database and sets the testing data. By default we
use a L<DBD::SQLite> database created
=cut
sub connect_and_setup {
my $class = shift @_;
my ($dsn, $user, $pass) = (
$ENV{DBIC_POPULATE_DSN} || $class->default_dsn,
$ENV{DBIC_POPULATE_USER} || '',
$ENV{DBIC_POPULATE_PASS} || '',
);
return $class
->connect($dsn, $user, $pass, { AutoCommit => 1 })
->setup;
}
=head2 default_dsn
returns a dsn string, suitable for passing to L<DBD::SQLite>, creating the
database as a temporary file.
=cut
sub default_dsn
{
return "dbi:SQLite:dbname=:memory:";
}
=head2 setup
deploy a database and populate it with the initial data
=cut
sub setup {
my $self = shift @_;
$self->deploy();
return $self;
}
=head2 cleanup
cleanup any temporary files
=cut
sub cleanup {
my $self = shift @_;
}
sub DESTROY {
(shift)->cleanup;
}
=head1 AUTHOR
Please see L<DBIx::Class::Schema::PopulateMore> For authorship information
=head1 LICENSE
Please see L<DBIx::Class::Schema::PopulateMore> For licensing terms.
=cut
1;
|