button labels for action form
[catagits/Reaction.git] / lib / Reaction / Test / WithDB.pm
CommitLineData
7adfd53f 1package Reaction::Test::WithDB;
2
3use base qw/Reaction::Test/;
4use Reaction::Class;
5
6has 'schema' => (
7 isa => 'DBIx::Class::Schema', is => 'rw',
8 set_or_lazy_build('schema')
9);
10
11has 'schema_class' => (
12 isa => 'Str', is => 'rw', set_or_lazy_fail('schema_class')
13);
14
15has 'connect_info' => (
16 isa => 'ArrayRef', is => 'rw', required => 1, lazy => 1,
17 default => sub { [ 'dbi:SQLite:t/var/reaction_test_withdb.db' ] },
18);
19
20override 'new' => sub {
21 my $self = super();
22 $self->BUILDALL;
23 return $self;
24};
25
26sub BUILD {
27 my ($self) = @_;
28 my $schema = $self->schema_class->connect(@{$self->connect_info});
29 $schema->deploy({ add_drop_table => 1 });
30 $schema->setup_test_data if $schema->can('setup_test_data');
31 $self->schema($schema);
32}
33
341;
35
36=head1 NAME
37
38Reaction::Test::WithDB
39
40=head1 DESCRIPTION
41
42=head2 new
43
44=head2 BUILD
45
46Deploys database schema, dropping tables if they already exist.
47
48=head1 ATTRIBUTES
49
50=head2 schema
51
52L<DBIx::Class::Schema>
53
54=head2 schema_class
55
56=head2 connect_info
57
58Uses C<[ dbi:SQLite:t/var/reaction_test_withdb.db ]> by default.
59
60=head1 SEE ALSO
61
62L<Reaction::Test>
63
64=head1 AUTHORS
65
66See L<Reaction::Class> for authors.
67
68=head1 LICENSE
69
70See L<Reaction::Class> for the license.
71
72=cut