| Reaction documentation | Contained in the Reaction distribution. |
Reaction::Test::WithDB
Deploys database schema, dropping tables if they already exist.
Uses [ dbi:SQLite:t/var/reaction_test_withdb.db ] by default.
See Reaction::Class for authors.
See Reaction::Class for the license.
| Reaction documentation | Contained in the Reaction distribution. |
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;