Reaction::Test::WithDB - Reaction::Test::WithDB documentation


Reaction documentation Contained in the Reaction distribution.

Index


Code Index:

NAME

Top

Reaction::Test::WithDB

DESCRIPTION

Top

new

BUILD

Deploys database schema, dropping tables if they already exist.

ATTRIBUTES

Top

schema

DBIx::Class::Schema

schema_class

connect_info

Uses [ dbi:SQLite:t/var/reaction_test_withdb.db ] by default.

SEE ALSO

Top

Reaction::Test

AUTHORS

Top

See Reaction::Class for authors.

LICENSE

Top

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;