blob: 465a4a039cec69d2fd2748aa7cfd8680a3d01c8b (
plain) (
blame)
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
|
package Reaction::Test::WithDB;
use base qw/Reaction::Test/;
use Reaction::Class;
has 'schema' => (
isa => 'DBIx::Class::Schema', is => 'rw',
set_or_lazy_build('schema')
);
has 'schema_class' => (
isa => 'Str', is => 'rw', set_or_lazy_fail('schema_class')
);
has 'connect_info' => (
isa => 'ArrayRef', is => 'rw', required => 1, lazy => 1,
default => sub { [ 'dbi:SQLite:t/var/reaction_test_withdb.db' ] },
);
override 'new' => sub {
my $self = super();
$self->BUILDALL;
return $self;
};
sub BUILD {
my ($self) = @_;
my $schema = $self->schema_class->connect(@{$self->connect_info});
$schema->deploy({ add_drop_table => 1 });
$schema->setup_test_data if $schema->can('setup_test_data');
$self->schema($schema);
}
1;
=head1 NAME
Reaction::Test::WithDB
=head1 DESCRIPTION
=head2 new
=head2 BUILD
Deploys database schema, dropping tables if they already exist.
=head1 ATTRIBUTES
=head2 schema
L<DBIx::Class::Schema>
=head2 schema_class
=head2 connect_info
Uses C<[ dbi:SQLite:t/var/reaction_test_withdb.db ]> by default.
=head1 SEE ALSO
L<Reaction::Test>
=head1 AUTHORS
See L<Reaction::Class> for authors.
=head1 LICENSE
See L<Reaction::Class> for the license.
=cut
|